Platforms to show: All Mac Windows Linux Cross-Platform

Back to SortMBS module.

SortMBS.SortMBS(extends theArray() as Double, 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
// disable background threads, which would slow us down
#Pragma BackgroundTasks False

Var a(10000000) As Double
Var b(10000000) As Double
Var c(10000000) As Double

Var u As Integer = a.ubound
For i As Integer = 0 To u
Var n As Integer = i Mod 1000
a(i) = n
b(i) = n
c(i) = n

Next

Var m1 As Double = Microseconds
a.Sort
Var m2 As Double = Microseconds
b.SortMBS
Var m3 As Double = Microseconds
c.SortMBS True // reverse
Var m4 As Double = Microseconds

Var XojoSort As Double = (m2 - m1) / 1000.0 // e.g. 142
Var MBSSort As Double = (m3 - m2) / 1000.0 // e.g. 128
Var MBSSortReverse As Double = (m4 - m3) / 1000.0 // e.g. 120

MessageBox "Xojo: "+XojoSort.ToString+EndOfLine+"MBS Sort: "+MBSSort.ToString+EndOfLine+"MBS Sort reverse: "+MBSSortReverse.ToString
Break

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

See also:

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:

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


The biggest plugin in space...