How to sort data file in matlab , I only want to sort 1st column in ascending order and want the other entries linked with it are automatically arranged.as 1st colum is a no other are properties of it.

2 views (last 30 days)
1.2000000e+02 1.4000000e+02 1.4998210e+04 3.7410889e+04 2.2669271e-01
1.1700000e+02 1.3700000e+02 1.4894970e+04 3.4887288e+04 2.4574382e-01
1.1800000e+02 1.3800000e+02 1.4960620e+04 3.7123210e+04 2.2906901e-01
1.1900000e+02 1.3900000e+02 1.4987342e+04 3.7271322e+04 2.2718913e-01
1.1000000e+01 3.1000000e+01 9.8520152e+03 1.4934896e+04 2.5934245e-01
1.2100000e+02 1.4100000e+02 1.5048622e+04 3.8070272e+04 2.2163900e-01
3.2000000e+01 5.2000000e+01 1.2213744e+04 2.2769165e+04 2.3404948e-01
3.3000000e+01 5.3000000e+01 1.2316004e+04 2.3439941e+04 2.2911784e-01
1.2200000e+02 1.4200000e+02 1.5044815e+04 3.8125814e+04 2.2242839e-01
1.2300000e+02 1.4300000e+02 1.5081111e+04 3.8755290e+04 2.1865234e-01
1.2400000e+02 1.4400000e+02 1.5089989e+04 3.9023031e+04 2.1673177e-01
3.1000000e+01 5.1000000e+01 1.2139682e+04 2.2351888e+04 2.3717448e-01
3.4000000e+01 5.4000000e+01 1.2367802e+04 2.3189290e+04 2.3623047e-01
3.5000000e+01 5.5000000e+01 1.2387013e+04 2.2249349e+04 2.5078125e-01

Answers (3)

Orion
Orion on 8 Oct 2014
Hi,
you just need to use sort
A = magic(5);
[unused,order] = sort(A(:,1));
A(:,:) = A(order,:);

Guillaume
Guillaume on 8 Oct 2014
A = sortrows(A, 1); %or just sortrows(A)

Stephen23
Stephen23 on 8 Oct 2014
This is exactly what sortrows is for.

Categories

Find more on Shifting and Sorting Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!