How can I sort an array with two columns?
2 ビュー (過去 30 日間)
古いコメントを表示
If I have an array of student ID in column1 and GPAs in column2
Info = [52211 3.55; 52922 1.79; 51939 3.33; 12140 0.81]
How can I sort the array from the highest GPA to the lowest GPA.
0 件のコメント
採用された回答
その他の回答 (2 件)
KSSV
2018 年 10 月 8 日
Info = [52211 3.55; 52922 1.79; 51939 3.33; 12140 0.81] ;
[val,idx] = sort(Info(:,2),'descend') ;
iwant = Info(idx,:)
0 件のコメント
Kevin Chng
2018 年 10 月 8 日
Hi,
Info = [52211 3.55; 52922 1.79; 51939 3.33; 12140 0.81];
[~,I] = sort(Info(:,2),'descend');
Info(I,:);
Done!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!