SortMBS methods

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

Back to SortMBS module.

Previous items Next items

SortMBS.SortArrayMBS(theArray() as Color, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts a color array.
Example
Dim test() As Color = Array(&cFF000, &c00FF00, &c0000FF, &c000000, &cFFFFFF)

SortArrayMBS test

Break // see in debugger

// now reverse it
SortArrayMBS test, True

Break // see in debugger

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

See also:

SortMBS.SortArrayMBS(theArray() as Color, theDelegate as SortVariantDelegateColorMBS, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts a color array using a delegate to compare.

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

Your delegate should be fast and return 0 if both values are equal, 1 if first value is bigger or -1 if first value is smaller.

See also:

SortMBS.SortArrayMBS(theArray() as Currency, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts a currency array.
Example
Dim test() As Currency
test.Append 1.2
test.Append -1.2
test.Append 12345
test.Append 3456

SortArrayMBS test

Break // see in debugger

// now reverse it
SortArrayMBS test, True

Break // see in debugger

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

See also:

SortMBS.SortArrayMBS(theArray() as Currency, theDelegate as SortVariantDelegateCurrencyMBS, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts a currency array using a delegate to compare.

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

Your delegate should be fast and return 0 if both values are equal, 1 if first value is bigger or -1 if first value is smaller.

See also:

SortMBS.SortArrayMBS(theArray() as Date, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Sorts a date array.
Example
Dim test() As Date
test.Append New date
test.Append New date(2023, 4, 5)
test.Append New date(2011, 3, 10)
test.Append New date(2033, 6, 22)

SortArrayMBS test

Break // see in debugger

// now reverse it
SortArrayMBS test, True

Break // see in debugger

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

See also:

SortMBS.SortArrayMBS(theArray() as DateTime, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts a DateTime array.
Example
Dim test() As DateTime
test.Append DateTime.Now
test.Append DateTime.FromString("2011-04-24")
test.Append DateTime.FromString("2022-03-21")
test.Append DateTime.FromString("2033-10-10")

SortArrayMBS test

Break // see in debugger

// now reverse it
SortArrayMBS test, True

Break // see in debugger

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

See also:

SortMBS.SortArrayMBS(theArray() as DateTime, theDelegate as SortVariantDelegateDateTimeMBS, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts a datetime array using a delegate to compare.

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

Your delegate should be fast and return 0 if both values are equal, 1 if first value is bigger or -1 if first value is smaller.

See also:

SortMBS.SortArrayMBS(theArray() as Double, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts a double array.
Example
Dim test() As Double = Array(5.0, -2, 3, -4, 1)

SortArrayMBS test

Break // see in debugger

// now reverse it
SortArrayMBS test, True

Break // see in debugger

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

See also:

SortMBS.SortArrayMBS(theArray() as Double, theDelegate as SortVariantDelegateDoubleMBS, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts a double array using a delegate to compare.

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

Your delegate should be fast and return 0 if both values are equal, 1 if first value is bigger or -1 if first value is smaller.

See also:

SortMBS.SortArrayMBS(theArray() as Int32, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts an Int32 array.

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

See also:

SortMBS.SortArrayMBS(theArray() as Int32, theDelegate as SortVariantDelegateInt32MBS, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts an Int32 array using a delegate to compare.

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

Your delegate should be fast and return 0 if both values are equal, 1 if first value is bigger or -1 if first value is smaller.

See also:

SortMBS.SortArrayMBS(theArray() as Int64, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts an Int64 array.
Example
Dim test() As Integer = Array(5, -2, 3, -4, 1)

SortArrayMBS test

Break // see in debugger

// now reverse it
SortArrayMBS test, True

Break // see in debugger

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

See also:

SortMBS.SortArrayMBS(theArray() as Int64, theDelegate as SortVariantDelegateInt64MBS, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts an Int64 array using a delegate to compare.
Example
Public Function CompareNumber(v1 as Integer, v2 as Integer) As integer
// we compare the absolute values, so 3 and -3 are next to each other in the result
v1 = Abs(v1)
v2 = Abs(v2)

If v1 = v2 Then
Return 0
ElseIf v1 < v2 Then
Return -1
Else
Return 1
End If
End Function

Sub Test
Dim testInteger() As Integer = Array(1,3,6,1,2,-3,0,9)
SortArrayMBS testInteger, AddressOf CompareNumber

Break // see in debugger
End Sub

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

Your delegate should be fast and return 0 if both values are equal, 1 if first value is bigger or -1 if first value is smaller.

See also:

SortMBS.SortArrayMBS(theArray() as Ptr, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts a ptr array.

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

See also:

SortMBS.SortArrayMBS(theArray() as Ptr, theDelegate as SortVariantDelegatePtrMBS, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts a Ptr array using a delegate to compare.

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

Your delegate should be fast and return 0 if both values are equal, 1 if first value is bigger or -1 if first value is smaller.

See also:

SortMBS.SortArrayMBS(theArray() as Single, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts a single array.

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

See also:

SortMBS.SortArrayMBS(theArray() as Single, theDelegate as SortVariantDelegateSingleMBS, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts a single array using a delegate to compare.

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

Your delegate should be fast and return 0 if both values are equal, 1 if first value is bigger or -1 if first value is smaller.

See also:

SortMBS.SortArrayMBS(theArray() as String, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts a string array.
Example
Dim testString() As String = Array("c", "b", "e", "d", "a")

SortArrayMBS testString

Break // see in debugger

// now reverse it
SortArrayMBS testString, True

Break // see in debugger

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

See also:

SortMBS.SortArrayMBS(theArray() as String, theDelegate as SortVariantDelegateStringMBS, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts a string array using a delegate to compare.
Example
Public Function CompareString2ndWord(s1 as string, s2 as string) As integer
// sort by second word

s1 = s1.NthField(" ",2)
s2 = s2.NthField(" ",2)

Return s1.Compare(s2)
End Function

Sub Test
Dim testString() As String = Array("Hello World", "Hallo Leute", "World Test", "First Entry", "abc def", "abc xyz")
SortArrayMBS testString, AddressOf CompareString2ndWord

Break // see in debugger
End Sub

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

Your delegate should be fast and return 0 if both values are equal, 1 if first value is bigger or -1 if first value is smaller.

See also:

SortMBS.SortArrayMBS(theArray() as UInt32, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts an UInt32 array.

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

See also:

SortMBS.SortArrayMBS(theArray() as UInt32, theDelegate as SortVariantDelegateUInt32MBS, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts an UInt32 array using a delegate to compare.

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

Your delegate should be fast and return 0 if both values are equal, 1 if first value is bigger or -1 if first value is smaller.

See also:

SortMBS.SortArrayMBS(theArray() as UInt64, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts an UInt64 array.

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

See also:

SortMBS.SortArrayMBS(theArray() as UInt64, theDelegate as SortVariantDelegateUInt64MBS, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts an UInt64 array using a delegate to compare.

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

Your delegate should be fast and return 0 if both values are equal, 1 if first value is bigger or -1 if first value is smaller.

See also:

SortMBS.SortArrayMBS(theArray() as Variant, theDelegate as SortVariantDelegateVariantMBS, descending as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts a variant array using a delegate to compare.

Does nothing for arrays with theArray.count < 2.
Pass true for descending to reverse the order.

Your delegate should be fast and return 0 if both values are equal, 1 if first value is bigger or -1 if first value is smaller.

See also:

SortMBS.SumArrayMBS(source() as Boolean, sourceIndex as Integer = 0, sourceCount as Integer = -2) as Int64

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sums up all the numbers in the array.

You can limit range by passing in a source index and source count.
If sourceCount is -2, we sum up whole array - sourceIndex.

Returns the sum of all values.

See also:

SortMBS.SumArrayMBS(source() as Currency, sourceIndex as Integer = 0, sourceCount as Integer = -2, CheckOverflow as Boolean = false) as Currency

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sums up all the numbers in the array.
Example
Dim v() As Currency

// just sum up some currency values
v.Add 123.4567
v.Add 1
v.add 0
v.add -56
v.add 4567

Dim m1 As Double = Microseconds
Dim sum1 As Currency = SumArrayMBS(v, True)
Dim m2 As Double = Microseconds
Dim sum2 As Currency = SumArrayMBS(v, False)
Dim m3 As Double = Microseconds

Dim d1 As Double = m2-m1
Dim d2 As Double = m3-m2
// overflow checking can make it 100 times slower

// try to cause an overflow with huge numbers
v.add 100000000000000.0000
v.add 200000000000000.0000
v.add 300000000000000.0000
v.add 400000000000000.0000

Dim sum3 As Currency = SumArrayMBS(v, False)
Dim sum4 As Currency = SumArrayMBS(v, True)

Break

You can limit range by passing in a source index and source count.
If sourceCount is -2, we sum up whole array - sourceIndex.
Pass true for overflow check to detect overflows for each addition. Otherwise pass false for better performance.
Returns the sum of all values.

See also:

SortMBS.SumArrayMBS(source() as Double, sourceIndex as Integer = 0, sourceCount as Integer = -2) as Double

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sums up all the numbers in the array.
Example
Const u = 99999
Dim v(u) As Double

For i As Integer = 0 To u
v(i) = i
Next

Dim m1 As Double = Microseconds
Dim sumPlugin As Int64 = SumArrayMBS(v)
Dim m2 As Double = Microseconds
Dim sumXojo As Double
For i As Integer = 0 To u
sumXojo = sumXojo + v(i)
next
Dim m3 As Double = Microseconds

Dim timePlugin As Double = m2-m1
Dim timeXojo As Double = m3-m2
// plugin is faster than Xojo code

Break

You can limit range by passing in a source index and source count.
If sourceCount is -2, we sum up whole array - sourceIndex.
Returns the sum of all values.

See also:

SortMBS.SumArrayMBS(source() as Int32, sourceIndex as Integer = 0, sourceCount as Integer = -2) as Int64

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sums up all the numbers in the array.

You can limit range by passing in a source index and source count.
If sourceCount is -2, we sum up whole array - sourceIndex.
We use Int64 as result may be bigger than Int32.
Returns the sum of all values.

See also:

SortMBS.SumArrayMBS(source() as Int64, sourceIndex as Integer = 0, sourceCount as Integer = -2, CheckOverflow as Boolean = false) as Int64

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sums up all the numbers in the array.
Example
Dim v() As Int64

// just sum up some currency values
v.Add 1234567
v.Add 1
v.add 0
v.add -56
v.add 4567

Dim m1 As Double = Microseconds
Dim sum1 As Int64 = SumArrayMBS(v, True)
Dim m2 As Double = Microseconds
Dim sum2 As Int64 = SumArrayMBS(v, False)
Dim m3 As Double = Microseconds

Dim d1 As Double = m2-m1
Dim d2 As Double = m3-m2
// overflow checking can make it 100 times slower

// try to cause an overflow with huge numbers
v.add 1000000000000000000
v.add 2000000000000000000
v.add 3000000000000000000
v.add 4000000000000000000

Dim sum3 As Int64 = SumArrayMBS(v, False)
Dim sum4 As Int64 = SumArrayMBS(v, True)

Break

You can limit range by passing in a source index and source count.
If sourceCount is -2, we sum up whole array - sourceIndex.
Pass true for overflow check to detect overflows for each addition. Otherwise pass false for better performance.
Returns the sum of all values.

See also:

SortMBS.SumArrayMBS(source() as Single, sourceIndex as Integer = 0, sourceCount as Integer = -2) as Double

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sums up all the numbers in the array.

You can limit range by passing in a source index and source count.
If sourceCount is -2, we sum up whole array - sourceIndex.

Returns the sum of all values.

See also:

SortMBS.SumArrayMBS(source() as UInt32, sourceIndex as Integer = 0, sourceCount as Integer = -2, CheckOverflow as Boolean = false) as UInt64

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Sort MBS Util Plugin 24.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sums up all the numbers in the array.

You can limit range by passing in a source index and source count.
If sourceCount is -2, we sum up whole array - sourceIndex.
Pass true for overflow check to detect overflows for each addition. Otherwise pass false for better performance.
Returns the sum of all values.

See also:

Previous items Next items

The items on this page are in the following plugins: MBS Util Plugin.


💬 Ask a question or report a problem