| grima (6) | |
|
Hi all, I would like to sort two arrays (two vectors) after the first and then after the second array in ascending order. Is there a quick way? Thanks, grima | |
|
|
|
| AleaIactaEst (99) | |
| Can you explain what you're trying to achieve more in detail ? | |
|
|
|
| grima (6) | |||||
|
Hi AleaIactaEst, yes I can ;) I have to arrays:
and my goal is to sort the arrays this way:
Thanks and best wishes, grima | |||||
|
|
|||||
| AleaIactaEst (99) | |||
The best way to achieve this is to use a struct like this:
At first sort the array ab with any sorting algorithm with respect to the value of b. After that you just need to sort the array again using a stable sorting algorithm for the a component. For more detailed information about stable sorting algorithms see Wikipedia (http://en.wikipedia.org/wiki/Sorting_algorithm#Stability) or do a search for stable sorting algorithms. | |||
|
|
|||