|
-
May 11th, 2002, 06:16 PM
#1
Thread Starter
Hyperactive Member
Sorting Challenge for the brave :)
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
-
May 12th, 2002, 02:12 AM
#2
Not NoteMe
Not sure what you've done there, (where are the arrays?), but you should be able to do whatever you did before, but put it all in a loop:
VB Code:
For i = 0 to Ubound(2DArray) 'May need to manually type this in, and VB has a thing about 2d arrays
'Code to sort 1D array replacing things like Array(j) with Array(i,j) (or array(j,i) depending on how youve done it)
Next i
Hope this helps, sorry i couldn't be more specific.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|