MATLAB: Sort cell array columns by two dimensions

cell arraysortsortrows

I want to sort the columns of a cell array along the first two rows.
The array has this form (the top row is already sorted):
array = {'A' 'A' 'B' 'B' 'B' 'C' 'C'; ...
1 0.1 1 0.1 0.5 1 0.1; ...
2 3 2 4 5 2 3}
And I would like the output to be in this form:
array = {'A' 'A' 'B' 'B' 'B' 'C' 'C'; ...
0.1 1 0.1 0.5 1 0.1 1; ...
3 2 4 5 2 3 2}
Thanks in advance!

Best Answer

array = {'A' 'A' 'B' 'B' 'B' 'C' 'C'
1 0.1 1 0.1 0.5 1 0.1
2 3 2 4 5 2 3}
array=sortrows(array',[1,2])'