Re: Using sortrows on mixed-type cell arrays
- From: "David the Dude" <dude@xxxxxxxxxxxxxxxxxx>
- Date: Mon, 15 May 2006 16:38:52 -0400
Thank you for your reply Jos, I'll try and explain:
I am trying to sort a log file with the fields:
<time> <user> <url>
I read the log file into a Matlab cell array, everthing is string
apart from <time> which has been converted using timevec - I
will use plain text below though to illustrate what I am trying to
do.
Here is an example:
15.05.2006 23:30 Bob <http://somesite.com/>
15.05.2006 23:29 Cat <http://anothersite.com/>
15.05.2006 23:31 Bob <http://pr0nsite.com/>
15.05.2006 04:20 Cat <http://newssite.com/>
I now want to sort the rows of the array first by <user> then
by <time> ... for the above example:
sorting by <user> results in (Bob "<" Cat):
15.05.2006 23:30 Bob <http://somesite.com/>
15.05.2006 23:31 Bob <http://pr0nsite.com/>
15.05.2006 23:29 Cat <http://anothersite.com/>
15.05.2006 04:20 Cat <http://newssite.com/>
Next, the array should be sorted by time so in the example the two
Cat entries are swapped since 04:20 < 23.29 to result in:
15.05.2006 23:30 Bob <http://somesite.com/>
15.05.2006 23:31 Bob <http://pr0nsite.com/>
15.05.2006 04:20 Cat <http://newssite.com/>
15.05.2006 23:29 Cat <http://anothersite.com/>
The problem - again - is that <time> is numerical whereares the
remaining fields are strings ... so SORTROWS doesn't work.
This is a pretty common task I guess so there's got be some simple
solution ...
Another thing, I really like MATLAB central - but would it be too
hard to have it use a fixed-width font ... for example code it would
be great.
.
- Follow-Ups:
- References:
- Re: Using sortrows on mixed-type cell arrays
- From: David the Dude
- Re: Using sortrows on mixed-type cell arrays
- From: Jos
- Re: Using sortrows on mixed-type cell arrays
- Prev by Date: Re: How Do I generate correlated random variables without using Cholsesky Decomp
- Next by Date: terminate m-file
- Previous by thread: Re: Using sortrows on mixed-type cell arrays
- Next by thread: Re: Using sortrows on mixed-type cell arrays
- Index(es):
Relevant Pages
|