Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: sorting dates with corresponding strings data
Replies: 2   Last Post: Aug 4, 2013 12:56 AM

 Messages: [ Previous | Next ]
 Larry Rose Posts: 20 Registered: 3/10/11
sorting dates with corresponding strings data
Posted: Aug 3, 2013 11:32 PM

hello, I need to sort dates and need to have string data be sorted along with it's corresponding date. I don't think I can use chars because the text data are not all the same length and don't think I can use cells since I can not include cells in a rowsort(x,[1]) function. Someone must know how to do this and I will be most grateful for any help.

Here is what I have been working with:
x=datenum(2008,08,05)
y=datenum(2007,07,04)
z=datenum(2006,02,03)

xyz={datestr(y);datestr(x);datestr(z)} % matlab will sort this
% c=char('tim','clare','sin')% no, char arrays are sensative to length of the word
% c={'tim';'clare';'sin'} % no, can't row sort a cell
xyzc=[xyz,c] %
rowsort(xyzc,[1]) %i can't get this to work

Thank you,
larry

Date Subject Author
8/3/13 Larry Rose
8/4/13 Derek Goring
8/4/13 Larry Rose