I neglected to mention that I’ve discovered a way to “overflow” the date object…
As a matter of fact, as soon as my Brand New Apple iBook arrives!!! I intend to release my VasSortLib. It will be the first of a series of Vanilla AppleScript libraries that I intend to get off my chest, after which, I hope to be rid of this silly language forever.
Here is the API:
isort( list, startIndex, endIndex )
qsort( list, startIndex, endIndex )
csort( list, startIndex, endIndex, sortsBeforeHandlerOrScriptObject )
ItemSort( list )
CustomItemSort( list, sortsBeforeHandlerOrScriptObject )
DateSort( list, dateParseParam )
AlphaNumSort( list )
ItemShuffle( list )
GetSortOrder( list )
SetSortOrder( list, indices, paramOneIsListOfListsBoolean )
FolderSort( folder-spec, nestedContentsBoolean, sortByParam )
SystemSort( alias list, nestedContentsBoolean, sortByParam )
script ByLength's sortsBefore( item1, item2 )
script ByIndex's sortsBefore( item1, item2 )
script ByIndices's sortsBefore( item1, item2 )
script BySource's sortsBefore( item1, item2 )
script ByClass's sortsBefore( item1, item2 )
script ByAnything's sortsBefore( item1, item2 )
isort() and qsort() are implementations of insertion-sort
and quick-sort that Nigel and I recently hammered out. csort()
is a version of qsort() that takes a comparison handler, or
a script object with a comparison handler called sortsBefore().
Their terse names are not meant to suggest that they are
“internal” handlers, but simply that they are the “primary”
handlers upon which all the other handlers are based. For
speed, these three handlers also implement less error-checking
than the other handlers in the library.
ItemSort() is the basic sort, requiring that all items of
the list be compariable via AppleScript’s less than and greater
than operators, < >.
CustomItemSort() implements csort() without having to specify
a starting and ending index, (and with better error-checking).
DateSort() is a handler for the common problem of sorting
date-strings that come in a variety of formats, (not all of
which are automatically recognized by AppleScript’s
‘date (“date string”)’ coercion).
AlphaNumSort() is for sorting strings containing numbers,
such that “abc2def” would come before “abc20def”, etc.
ItemShuffle() is a quick randomizing sort.
GetSortOrder() returns indices into the list, indicating
the sort order, if you were to sort the list:
{“b”, “c”, “a”} → {2, 3, 1}
SetSortOrder() takes as its first parameter either a single
list to sort, or a list of lists to sort, based on an indice
list, (perhaps created by GetSortOrder()).
FolderSort() and SystemSort() will implement something along
the lines of what you suggest. There are two handlers because
it is easier and faster to start with a folder of items to
sort than it is to take a list of system items that might
have come from anywhere, even from two or more different volumes.
P.S. Why do the “code” blocks in BBCode not use monospaced fonts. I don’t understand what the point of marking something “code” is if it doesn’t make it look like code, (and especially if it doesn’t let it line up and align like code).