Sorting a Cell Array based in multiple dimenssion
1 view (last 30 days)
Show older comments
Dear all, I have a broblem with my Cell Array. I tried to use this function http://www.mathworks.com/help/toolbox/stats/dataset.sortrows.html but didn't work to me.. I have this cell array :
YPL-320 'SMITH' Male 38
GLI-532 'JOHNSON' Male 43
PNI-258 'WILLIAMS' Female 38
MIJ-579 'JONES' Female 40
XLK-030 'BROWN' Female 49
I would like to sort it based on 2th and 4th column:
REV-997 'ALEXANDER' Male 25
FZR-250 'HALL' Male 25
LIM-480 'HILL' Female 25
XUE-826 'JACKSON' Male 25
SCQ-914 'JAMES' Male 25
How can I do this?
Thanks & BRgds
2 Comments
Matt Fig
on 29 Aug 2012
Nothing about the second array is the same as the first! You don't show a sorted cell array, you show a different cell array....
Jan
on 29 Aug 2012
@Matt: Alexis shows the first 5 lines of the unsorted and the sorted array, while she hides the other 162 lines to improve the readability of the question.
We had a serious problem with our patient database, when a participator of a long term study changed his (or her?) sex. Of course the strict specifications of a clinical double blind study do not allow to modify the software such that the one or other patient can be included. Perhaps this would explain the 'Female' to 'Male' switch in the data.
Answers (1)
Andrei Bobrov
on 29 Aug 2012
B = { 'YPL-320' 'SMITH' 'Male' 38
'GLI-532' 'JOHNSON' 'Male' 43
'PNI-258' 'WILLIAMS' 'Female' 38
'MIJ-579' 'JONES' 'Female' 40
'XLK-030' 'BROWN' 'Female' 49}
sortrows(B,[2 4])
0 Comments
See Also
Categories
Find more on Frequently-used Algorithms 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!