Here is one way to do matrix sorting. Your description is a little confusing, but hopefully from this you see the general approach using the sort function.
>> A = [2 3; 1 2; 4 1; 6 7; 3 6; 7 10]
A =
2 3
1 2
4 1
6 7
3 6
7 10
>> [B, I] = sort(A(:,1))
B =
1
2
3
4
6
7
I =
2
1
5
3
4
6
>> Asorted = A(I,:)
Asorted =
1 2
2 3
3 6
4 1
6 7
7 10
