## Mathematical computation for ordering matrices

### arun Dhillon (view profile)

on 11 Mar 2019
Latest activity Commented on by arun Dhillon

on 11 Mar 2019

### Jos (10584) (view profile)

HEllo Everyone
I am having a variable matrix of the size n*2(please see attached image). The first column is all the x values and the second column is all the y values. I want to use all those x,y pairs in a sequence and run an algorithm on each of those x,y pairs. The way i want to use the sequence is that first the smallest y value and its coresponding x value should be chosen to run the algo. upon. Then the next bigger y value should be choosen and the corresponding x value with it must be used to run the algorithm upon. In case of attached image file. The first pair of x,y that should be choosen to run the algo upon should be 261.3794,62.5125; then second value to run the algo upon should be 423.0914,65.1643 and so on. Please edify me that how can i do the same.

### Jos (10584) (view profile)

on 11 Mar 2019

You can sort the values according to the second column using sortrows. Something along these lines might work for you:
centers = sortrows(centers, 2)
for k=1:size(centers, 1)
XY = centers(k,:) ;
RunMyAlgo (XY)
end

arun Dhillon

### arun Dhillon (view profile)

on 11 Mar 2019
Thank you so much Jos. It works great.