From: Pr B on
i have the following cell array i would like to sort:

the first column of the cell contains strings:

'a'
'b'
....

the second column of the cell contains ints:

'2'
'3'
'1'
'7'
....

i would like to sort the cell by column 2 in descending order, but sortrows doesn't work on this cell and gives me an error. what's the best way to do this sort?
From: us on
"Pr B" <pb2297(a)columbia.edu> wrote in message <hosbh2$dr1$1(a)fred.mathworks.com>...
> i have the following cell array i would like to sort:
>
> the first column of the cell contains strings:
>
> 'a'
> 'b'
> ...
>
> the second column of the cell contains ints:
>
> '2'
> '3'
> '1'
> '7'
> ...
>
> i would like to sort the cell by column 2 in descending order, but sortrows doesn't work on this cell and gives me an error. what's the best way to do this sort?

a hint:

help sortrows;

us
From: Jan Simon on
Dear Pr B!

> 'a'
> 'b'
> ...
>
> the second column of the cell contains ints:
>
> '2'
> '3'
> '1'
> '7'
> ...

Are you sure that these are INTs? Where do the quotes come from? Do you mean strings which contain integer numbers?

> i would like to sort the cell by column 2 in descending order, but sortrows doesn't work on this cell and gives me an error. what's the best way to do this sort?

"Doesn't work" and "gives me an error" is not enough to describe the problem. Please post a copy of the error message.
Take a look in SORTROWS. It should be possible to modify the source to work on mixed type input also.

Kind regards, Jan