Q:

Sort and index matrix

I have a variable data which is a 1xn double (n>15), something like this: 
50.12 55.93 58.78 67.36 67.90 100.12 2.35 168.73 ... 

First, I would like to keep only the first 15 highest values in data while removing the rest. This is easy to do. However, the complication is that each of the value in data is associated with a set of x y z coordinates in coord. coord is a 3xn double, something like this:
8 9 15 42 32 56 3
4 25 36 7 89 21 3
5 1 25 75 79 20 66...

For instance, the coordinates of data(1,1) would be coord(:,1) and the coordinates of data(1,6) would be coord(:,6). The challenge here is that I would also like remove the corresponding coordinates in coord that are associated with the removed values in data. That way, I would end up with 1x15 data and 1x15 coord. I thought about doing this: 
M=vertcat(data,coord) ;

then sort M by the first row and keep only the highest 15 values of the first rows to end up with 4x15. Finally, I split data and coord.
My questions are:
1. How can I sort M according to the first row in a way that the 2nd, 3rd, and 4th row are also reorganized accordingly?
2. My proposed solution seems messy. Does anyone have an elegant solution?

A:

sort will tell you where each element of the sorted array came from, you can use this to reorganise the columns of coord
[dataSorted,I] = sort(data,2,'descend')
dataTop15=dataSorted(1:15)
coordTop15=coord(:,I(1:15))

