Is there a way to sort a two dimensional array by row?
For example i would want to sort in ascending order between:
array[0][4]
array[1][4]
array[2][4]
So if the array was as follows:
3 8 7 2
9 12 0 4
12 2 14 1
it will sort to:
2 3 7 8
0 4 9 12
1 2 12 14
Any help would be greatly appreciated. Thanks!
There's no such thing as a two dimensional array.
Make your array like this
int array[hSize*vSize]
And access like this:
array[vSize*y+x]
If you want to sort in rows, let your algo march x
0<=x<vSize
In columns, let it march y
0<=y<hSize
and access as above.
Thank you Filipe :)
That worked great!