Hiya i have an array of information about blah blah..... not important :-) neway, each array element contains a numeric value that my program sorts by which is closest to a given value.

but now.. i have to turn this array into a two dimensional array, it will just be an array of elements, each element being an instance of the existing array (hope that makes sense). I'm going to use this to display the information, each array of array's will be a page of results (at this stage i just have one page, but i want to be able to show more results)

How can i sort the 2d array so it results in the same order as the existing array, i.e the ones closest to the value being at the start of the first array, and the ones futherest away at the end of the last array.


Here is the current sort if it's any help:

Dim i As Long
Dim j As Integer
Dim BagDiff1 As Single
Dim BagDiff2 As Single
Dim Biggest As Single
Dim tempb As BagShellType

Set tempb = New BagShellType

For i = 0 To (FinalBagCount - 1)
Biggest = i

For j = (i + 1) To FinalBagCount - 1
BagDiff1 = Absolute(BagArray(Biggest).O2 - Produce.GetOptO2)
BagDiff2 = Absolute(BagArray(j).O2 - Produce.GetOptO2)
If (BagDiff1 > BagDiff2) Then Biggest = j
Next

tempb.copybag bag:=BagArray(i)
BagArray(i).copybag bag:=BagArray(Biggest)
BagArray(Biggest).copybag bag:=tempb
Next