Sorting 2 Arrays ?

How do you perform a second level sort so that the user can choose to sort Column 1, and then if they want add a second level sort to column2?

Like for example if right now i have 3 arrays, and the first array has been sorted, what code should i use to let the user sort the second column.

(Where I'm at)(user chose to sort by make)

BMW -- 328i -- 2001
Honda -- Civic -- 2010
Jeep -- Wrangler -- 1999
Jeep -- Cherokee -- 2000
Jeep -- Grand Cherokee -- 2004

(Where I'm trying to get to)(user selects to second sort using the array model)

BMW -- 328i -- 2001
Honda -- Civic -- 2010
Jeep -- Cherokee -- 2000
Jeep -- Grand Cherokee -- 2004
Jeep -- Wrangler -- 1999
You already have a sorting algorithm that, when it determines that it has to rearrange, does the swap on all three columns?

Determines is the keyword. Your columns are "Make", "Model", "Year"? The determination is:
Make[i] > Make[j]

Now, lets make it more complex:
Make[i] > Make[j] || (Make[i] == Make[j] && Model[i] > Model[j])
In other words, swap rows i and j, IF Make is decending OR IF (Make is sorted AND Model is descending)
Topic archived. No new replies allowed.