Re: Sorting? [sorted]
Re: Sorting? [sorted]
- Subject: Re: Sorting? [sorted]
- From: John Delacour <email@hidden>
- Date: Fri, 13 Sep 2002 10:29:07 +0100
At 6:35 pm -0700 12/9/02, John W Baxter wrote:
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.
Something like this, you mean
set s to "page1_box0
page1_box1
page1_box10
page1_box11
page1_box12
page1_box13
page1_box14
page1_box15
page1_box16
page1_box17
page1_box18
page1_box19
page1_box2
page1_box20
page1_box21
page1_box22"
do shell script "perl -e '
for (split /\\r/, \"" & s & "\") {/(.+?)(\\d+$)/ ;
push @_, $1. sprintf \"d$/\", $2}
for (sort @_) {s~0+(\\d+)$~$1~ ; print }'"
Sorry to be so verbose.
JD
_______________________________________________
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.