16.05.2012, 19:01
Is there a way to sort an array without changing the order of the array which stores the data.
And to save the sorted IDs of the data-array in another array.
Example:
sortarray stores now the order of the sorted dataarray.
The value is the index of the item in the dataarray.
With this feature you could sort an array like Score[MAX_PLAYERS] without changing the order of the playerids.
I hope you understand what i mean
And to save the sorted IDs of the data-array in another array.
Example:
Код:
new dataarray[5][2] = { // Stores the data {512, 111}, // 0 {-42, 222}, // 1 {932, 333}, // 2 { 9, 444}, // 3 {-90, 555} // 4 }; new sortarray[5]; // Will store the order of the sorted data SortArray(dataarray, 0, sortarray);
The value is the index of the item in the dataarray.
Index | Value |
0 | 4 |
1 | 1 |
2 | 3 |
3 | 0 |
4 | 2 |
I hope you understand what i mean
![Smiley](images/smilies/smile.png)