Sort two dimensional array

Since Xojo can only sort a single item array, I am looking for a multi-dimensional alternative. I keep reading about Charles Yeoman’s sortLibrary, but I can’t find it anywhere. Does anyone have a solution or know how to get sortLibrary?

How is it you want it sorted? I never thought of this and a quick search turns up 2 different ways to sort…
http://stackoverflow.com/questions/15452429/java-arrays-sort-2d-array

[quote]so for ex, myArr contents is:
1 5
13 1.55
12 100.6
12.1 .85
I want it to get to :
1 5
12 100.6
12.1 .85
13 1.55[/quote]
http://stackoverflow.com/questions/19237419/sorting-2d-array-c

[quote]For example,
13, 14, 15, 16
1, 4, 3, 2
7, 5, 7, 6
9, 10, 11, 12
Becomes:
{ 1, 2, 3, 4 }
{ 5, 6, 7, 8 }
{ 9, 10, 11, 12 }
{ 13, 14, 15, 16 }[/quote]
Or is there some other sorting you’re after?

I think it went offline when Charles site went
Not sure he’s ever posted it elsewhere
I have a copy somewhere but I’d like to ask him if its ok to post it

An easy alternative way to do this is to make a class that contains the data for the columns as properties. When you want to sort just pull the appropriate property into a temporary array, and then use .sortWith(yourClassArray).

Although my answer obviously won’t work if you don’t have a fixed Y size. Not sure exactly what you’re trying to sort.

This might work…

[code]Sub sort2DIntegerArray(arr(,) As integer)
dim backbone(), lastX, lastY, x, y As integer, lists() As Variant

lastX = Ubound(arr, 2)
lastY = UBound(arr, 1)

redim lists(lastY)
redim backbone(lastY)

for y = 0 to lastY //copy out values

dim ta() As integer  //create and fill row array
redim ta(lastX)
for x = 0 to lastX
  ta(x) = arr(y, x)
next
//ta.Sort   //also sort rows?

lists(y) = ta    //store the row and its 0 element
backbone(y) = ta(0)

next

backbone.SortWith(lists) //sort on column 0

dim ta() As integer //write values back
for y = 0 to lastY
ta = lists(y)
for x = 0 to lastX
arr(y, x) = ta(x)
next
next
End Sub
[/code]