Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Sort lists in AppleScript using the Unix sort command' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Sort lists in AppleScript using the Unix sort command
Authored by: Graff on May 17, '04 09:36:55PM

Sure, bubblesort is slow for a large number of items. That's why I said that I have a bunch of different types of sorts programmed in AppleScript. If I want to sort a large list I'd use a quicksort or a heapsort, they are O(nlogn) - much faster than bubblesort which is O(n^2). If I really needed efficient sorting I would combine a quicksort and an insertion sort (for when the quicksort partition is 10 elements or less). However, if I'm sorting a ton of elements and time is a factor then AppleScript is the wrong tool in the first place...

Bubblesort is just fine for sorting lists of a few hundred items. It is small and easily understood and doesn't clutter up a script too much. For most AppleScript tasks it is perfect.



[ Reply to This | # ]