Sort so that "Hello" is always before "hello"

Thierry Douez th.douez at gmail.com
Fri May 19 10:09:33 EDT 2017


2017-05-19 15:44 GMT+02:00 hh
​:

> Thierry wrote:
> > sort lines of T numeric by AaZz_sort( each)
> > function AaZz_sort x
> >    get chartonum( char 1 of x)
> >    if IT > 96 then return ( IT - 96) * 2 + 1
> >    else return ( IT - 64) * 2
> > end AaZz_sort
>
>
> Hi Thierry,
>
> don't you need a second sort as 'primary' sort?
>

​Mmm, no ?
I thought that was the question from the OP... misreading  :)
​

>
> sort lines of T numeric by each & AaZz_sort( each) ?
> sort lines of T
>
> Else the container is sorted by the first char of each line only.
>

​Yes, you are right, so I rewrite it a bit to be more *readable*:


sort lines of T numeric by AaZz_sort(char 1 of each)

function AaZz_sort x
   get chartonum( x)
   if IT > 96 then return ( IT - 96) * 2 + 1
   else return ( IT - 64) * 2
end AaZz_sort
​


> But your ASCII-number-formula for uppercase/lowercase A-Za-z
> ordering is really worth to go in a lib!
>
> Hermann
>
> By the way, my "solution" is the following, that handles uppercase
> char before lowercase char sorting for each char of the lines.
>
>   set the casesensitive to true -- secondary sort:
>   sort myContainer
>   set the casesensitive to false -- primary sort:
>   sort myContainer
>
>
​I'll try to come up with something else later...

Thierry​

-- 
------------------------------------------------
Thierry Douez - sunny-tdz.com
sunnYrex - sunnYtext2speech - sunnYperl - sunnYmidi - sunnYmage



More information about the use-livecode mailing list