Click to See Complete Forum and Search --> : Problems with Sorting...


cusimar9
03-03-2006, 06:38 AM
I have a field in my database that I want to sort by, unfortunately its a calculated field and its too cumbersome to calculate using SQL.

I finally solved it by retrieving all the rows into a multi-dimensional array, and sort it using a modified QuickSort algorithm which does the job very nicely.

Unfortunately, our requirements have now changed so that I need to sort the array on 2 fields.

Now one of the fields I COULD sort using SQL, but then when the QuickSort algorithm sorts on the caculated field it'll jumble up the ordering again.

Can anyone recommend how I might be able to sort on 2 fields?

Maybe I need to modify the QSort algorithm some more to accommodate it...

cusimar9
03-05-2006, 12:43 PM
I've sorted it, just modified the QSort algorithm. Quite straightforward, actually

Since this thread has received many views but no replies, I may as well post the QSort algorithm incase anyone wants it

http://watson-net.com/free/asp/