I have a problem where I should sort out array of arrays and get sorted indexes of the array, I think some example will demonstrate my problem better than just describing by words. So, I present several examples:
1-example:
n=3
[1, 4] row=0
[2, 5]
[3, 6] row=2
output should be : 0 1 2 (explanation is below)
2-example:
n=5
[8, 9] row=0
[4, 6] row=1
[5, 11] row=2
[3, 4] row=3
[4, 7] row=4
[2, 6] row=5
output should be : 3 5 1 4 0 2(explanation is below)
Sorting criteria mainly based on second column's value, first I should print the second column's smallest value's index, in 1-example it is 4 and it's index is 0 . If we encounter same values in second column as in 2-example (1 and 5 rows are same) then we should compare first columns corresponding values and print the smaller one's index first. Another more precise example of the problem:
n=3
[4, 6] row=0
[1, 6] row=1
[2, 6] row=2
output should be : 1 2 0
EDIT: There is always 2 columns and n rows
comparefunction.