Re: Fastest Sort for text and numbers
Re: Fastest Sort for text and numbers
- Subject: Re: Fastest Sort for text and numbers
- From: "Arthur J Knapp" <email@hidden>
- Date: Tue, 01 May 2001 09:40:16 -0400
>
From: "Bourque, Jason" <email@hidden>
>
Subject: RE: Fastest Sort for text and numbers
>
Date: Mon, 30 Apr 2001 14:02:24 -0400
>
But this one does not work with text.
???
I don't understand what you mean. Did you try it with text?
set myList to {"ghi", "abc", "def"}
my qSort(myList, 1, length of myList)
myList
-- > {"abc", "def", "ghi"}
If you need to "consider" case, hyphens, etc, you can call
the handler from within a considering statement:
considering case and expansion
my qSort( myList, 1, length of myList )
etc.
>
> to qSort(lst, l, r)
>
> set {a, z, v} to {l, r, lst's item ((l + r) div 2)}
>
> repeat until z is less than or equal to a
>
> repeat while item a of lst < v
>
> set a to a + 1
>
> end repeat
>
> repeat while item z of lst > v
>
> set z to z - 1
>
> end repeat
>
> if a is less than or equal to z then
>
> set {lst's item z, lst's item a, a, z} to ,
>
> {lst's item a, lst's item z, a + 1, z - 1}
>
> end if
>
> end repeat
>
> if l < z then qSort(lst, l, z)
>
> if r > a then qSort(lst, a, r)
>
> end qSort
Arthur J. Knapp
http://www.stellarvisions.com
mailto:email@hidden
Hey, check out:
http://www.seanet.com/~jonpugh/