Platforms to show: All Mac Windows Linux Cross-Platform

Back to SortMBS module.

Previous items

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

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

test.SortMBS

Break // see in debugger

// now reverse it
test.SortMBS True

Break // see in debugger

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

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
Var 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

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

Var d1 As Double = m2-m1
Var 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

Var sum3 As Currency = SumArrayMBS(v, False)
Var 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
Var v(u) As Double

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

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

Var timePlugin As Double = m2-m1
Var 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 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
Var v() As Int64

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

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

Var d1 As Double = m2-m1
Var 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

Var sum3 As Int64 = SumArrayMBS(v, False)
Var 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 UInt64, 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.
Example
Const u = 99999
Var v(u) As UInt64

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

Var m1 As Double = Microseconds
Var sumPlugin As UInt64 = SumArrayMBS(v, False)
Var m2 As Double = Microseconds
Var sumPluginOverflowChecked As UInt64 = SumArrayMBS(v, True)
Var m3 As Double = Microseconds
Var sumXojo As UInt64
For i As Integer = 0 To u
sumXojo = sumXojo + v(i)
Next
Var m4 As Double = Microseconds


Var timePlugin As Double = m2-m1
Var timePluginOverflowChecked As Double = m3-m2
Var timeXojo As Double = m4-m3
// 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.
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

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


The biggest plugin in space...