Re: Sorting? [sorted]
Re: Sorting? [sorted]
- Subject: Re: Sorting? [sorted]
- From: John W Baxter <email@hidden>
- Date: Thu, 12 Sep 2002 18:35:38 -0700
At 19:44 +0100 9/12/2002, has wrote:
>
Since AS has no way of knowing you want to look at that part of the string
>
differently, you're going to have to do the extra work yourself. There are
>
two ways [1] of approaching this task:
Another choice (I looked at the footnote) is what the Perl crowd calls the
Schwartzian Transform. If something is hard to sort, you convert it to
something easy to sort, sort it, and convert the items in the result back.
My feeling is that for the problem at hand, that is probably not the best
approach...has' probably is. (AppleScript doesn't mash text very well, and
the transform method would require two mashings.)
Example: we have a bunch of lines like
name<tab>Sun Sep 1 09:12:09 2002<tab>other stuff
We want the major sort key to be the name field, and for each name we want
the lines sorted temporally. (We also want the lines to continue to be
human readable.)
Occasionally for reasons I don't understand, the file fails to sort...I
divide it into two parts (almost anywhere) and each sorts OK, and then the
merge aspect of Unix sort can put it back together OK. (BSDi Unix and its
sort command.) It's not a matter of size...usually much bigger files are
sorting OK in the same run.
When I get a chance, I'm going to rewrite the files to look like
name<tab>2002-09-01T09:12:09{and something for the weekday}<tab>other stuff
[If I'm going to change it, I might as well stay as close to ISO format as
convenient.] That will sort with a much simpler sort command (the second
field just sorts right...no messing about), and I'm expecting the error to
go away. In this case, I'm going to forget about the 'convert it back'
part of the transform...the code which uses the data can change to use this
form, and the people should have no problem.
The change will bail me out of another problem...I haven't been smart
enough to write a working sort command for the data-as-it-is in the venue
to which we'll be moving the data soon.
--John
--
John Baxter email@hidden Port Ludlow, WA, USA
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.