Sorting cells with headers... how to start sorting at row 2

I know this has to be simple, but I can't for the life of me figure it out.
I have a five Nx6 cell arrays that I'm trying to sort using the sortrows function. The cell arrays have a header row (row 1). It will sort the data, but it treats the header row the same as the other data and sorts it accordingly, moving it from its row 1 position to somewhere else.
Is there a way to use the sortrows function and tell it to sort from row 2 to the end?
For example, cell A is an Nx6 array, and I want to sort it by column 6. I'm using
A = sortrows(A,6);
I've seen something along the lines of
A = sortrows(A,A(2:end,6))
but that's not working.
Any help is appreciated.

 採用された回答

Michael Haderlein
Michael Haderlein 2014 年 10 月 28 日

0 投票

You have mixed up a bit in your suggestion of the solution:
sA=[A(1,:);sortrows(A(2:end,:),2)];

1 件のコメント

John
John 2014 年 10 月 28 日
Thank you. That worked perfectly!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeShifting and Sorting Matrices についてさらに検索

質問済み:

2014 年 10 月 28 日

コメント済み:

2014 年 10 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by