Re: Sorting A List - Need Help
Re: Sorting A List - Need Help
- Subject: Re: Sorting A List - Need Help
- From: Rick Bargerhuff alias cougar <email@hidden>
- Date: Sat, 26 Jul 2003 19:36:34 -0400
At 4:28 pm -0400 26/7/03, Rick Bargerhuff alias cougar wrote:
I was looking for an applescript sorting algorithm
Try this. I've written it so that it ought to work in any script
editor.
set ls to paragraphs of "untitled folder 15
untitled folder 16
untitled folder 19
untitled folder 201
untitled folder 3"
set my text item delimiters to ASCII character 10
set s to ls as Unicode text
set my text item delimiters to ""
do shell script "perl -e '
for (split qq~\\012~, qq~" & s & "~) {
s~\\d+~sprintf(\"d\",$&)~e;
push @ls2, $_}
for ( sort @ls2) {
s~ (0+)([1-9]+)~ $2~ ;
print qq~$_$/~};'"
Hey John,
Ok, this is a special case and would work if the file names were named
using the same scheme...
But my scenario would be global. Meaning I don't really know what the
naming scheme would be.
See Mac OS X Finder seems to sort the files correctly regardless if the
naming scheme is special or not.
I need to somehow reproduce that sorting algorithm the Finder uses. It
only seems right to mimic the Mac
OS X Finder's way of sorting. Now the bigger question is, is the
Finder's method of sorting correct? I been
doing alot of research on sorting and I have come to realize that there
is no real way to sort... it all boils down
to what your sorting. In this case, I'm sorting file names. But now
my problem is, there is 2 ways to sort file names,
Dictionary style, and numerically. Dictionary is what is returned by
the Finder in a list folder call... Numerically is
what the Finder does with a bunch of files with numerics at the end.
So it is a combination of the 2.
Hope that further explains the dilemma I'm in
Rick
_______________________________________________
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.