Sorting by item ... of each and item ... of each

matthias_livecode_150811 at m-r-d.de matthias_livecode_150811 at m-r-d.de
Sun Sep 3 08:20:51 EDT 2023


Thanks Panos,

you are right. ;)  While reading your answer i remembered that i have done this with 2 separate sorts.
I really don't know how i thought to use  by sortKey1 and sortKey2

But at least the script editor did not return an error.

Should not work so late in the night.

Matthias


> Am 03.09.2023 um 11:26 schrieb panagiotis m via use-livecode <use-livecode at lists.runrev.com>:
> 
> Hello Matthias,
> 
> I do not think that the syntax "sort <container> by sortKey1 and sortKey2"
> is supported
> 
> If you have multiple sortKeys, you have to do multiple sorts, for example,
> in your use case, this should work:
> 
> set the itemdel to ";"
> sort lines of tList numeric by item 3 of each
> sort lines of tList numeric by item 2 of each
> 
> Kind regards,
> Panos
> --
> 
> On Sun, 3 Sept 2023 at 08:23, Phil Davis via use-livecode <
> use-livecode at lists.runrev.com> wrote:
> 
>> I believe this works:
>> 
>>    on mouseUp
>>         put fld 1 into tList
>>         sort lines of tList by _sortKey(each)
>>         put tList into fld 2
>>    end mouseUp
>> 
>> 
>>    function _sortKey pLine
>>         set the itemDel to ";"
>>         return item 3 of pLine & ";" & item 2 of pLine
>>    end _sortKey
>> 
>> 
>> I realize it isn't as simple as you were looking for, but at least it
>> avoids doing 2 separate sorts.
>> 
>> Phil Davis
>> 
>> 
>> 
>> On 9/2/23 6:03 PM, matthias rebbe via use-livecode wrote:
>>> Of course my "not working" sort code look like this
>>> 
>>> set the itemdelimiter to  ";"
>>> sort lines of tList numeric by item 3 of each and item 2 of each.
>>> 
>>> 
>>> 
>>> 
>>>> Am 03.09.2023 um 02:59 schriebmatthias_livecode_150811 at m-r-d.de:
>>>> 
>>>> Maybe i do not see the forest for the trees....
>>>> 
>>>> I have a tab delimited list which i want to sort. I am using this code
>> to sort it by item 3 and  item 2
>>>> 
>>>> set the itemdelimiter to tab
>>>> sort lines of tList numeric by item 3 of each and item 2 of each.
>>>> 
>>>> But that code does not sort as i expected it. Column 2 is not sorted
>> correctly.
>>>> The following list is the result.
>>>> 
>>>> 113254;8420;3016365
>>>> 113254;8423;3016365
>>>> 113254;8422;3016365
>>>> 113254;8420;3016365
>>>> 113254;8420;3016365
>>>> 113254;8420;3016365
>>>> 113254;8421;3016365
>>>> 203212;8420;3016366
>>>> 203212;8423;3016366
>>>> 203212;8422;3016366
>>>> 203212;8420;3016366
>>>> 
>>>> 
>>>> My expectation for example  was that for value 3016365 in column 3 the
>> values in Col 2 would be sorted like this
>>>> 
>>>> 113254;8423;3016365
>>>> 113254;8422;3016365
>>>> 113254;8421;3016365
>>>> 113254;8420;3016365
>>>> 113254;8420;3016365
>>>> 113254;8420;3016365
>>>> 113254;8420;3016365
>>>> 
>>>> Tried also    'by item 2 of each and item 3 of each', but the sort
>> result is the same?
>>>> 
>>>> Am i missing something?
>>>> 
>>>> Regards,
>>>> Matthias
>>>> 
>>> 
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>> 
>> 
>> --
>> Phil Davis
>> (503) 307-4363
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list