Sort a Matrix based on a column
1 view (last 30 days)
Show older comments
Kris zenitis
on 9 Dec 2011
Commented: Azzi Abdelmalek
on 19 Feb 2014
I want to sort a matrix. Actually I want to sort the last column and all the rest columns based on the last. Has anyone idea about this???
0 Comments
Accepted Answer
Walter Roberson
on 9 Dec 2011
[lastvals, idx] = sort(A(:,end));
sortedA = A(idx,:);
2 Comments
Azzi Abdelmalek
on 19 Feb 2014
[Kris zenitis commented]
I ve got a matrix 4000x9. When i tried your solution i got Index exceeds matrix dimensions.
More Answers (0)
See Also
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!