Re: sort bug

2023-09-07 Thread Bob Sneidar via use-livecode
I’ve always thought that an operator like “a list of…” might be handy. In this case a list of integers, so you could check to see if the list you want to sort is a valid list of integers. Bob S On Sep 7, 2023, at 9:02 AM, Brian Milby via use-livecode wrote: It seems the error/bug is

Re: sort bug

2023-09-07 Thread Bob Sneidar via use-livecode
I think it is putting all non-numeric values first as unsortable, then the sortable items next. This seems to be the case because: put "b,4,2,a,3,6" into tList;sort items of tList numeric ascending;put tList Results in: b,a,2,3,4,6 This implies that the non-numeric items are not being sorted

Re: sort bug

2023-09-07 Thread Brian Milby via use-livecode
It seems the error/bug is related to the error being in the last value. If you were to change the bug report to sort on the field itself, then the sort is performed but the answer does not execute. If you clicked the button again, then the answer does show. If you revert to the saved stack

Re: sort bug

2023-09-07 Thread Craig Newman via use-livecode
Bob, If you remove the “numeric” the result is “2,3,4,6,a”. To me this implies that ASCII values are used as the sortKey. But that begs the issue why, as in your post, with “numeric” included, the “a” appears first. What makes the “a” a lower "numeric" value than “2”? Craig > On Sep 7, 2023,

Re: sort bug

2023-09-07 Thread Bob Sneidar via use-livecode
For me, put "4,2,a,3,6" into tList;sort items of tList numeric ascending;put tList Results in: a,2,3,4,6 Bob S > On Sep 6, 2023, at 7:29 PM, Geoff Canyon via use-livecode > wrote: > > From the original email: > > If the function myVal encounters a run-time error (in the example if one of

Re: Sort bug and also multilevel sorting

2023-09-07 Thread Craig Newman via use-livecode
Neville. My example was only to show that the sort command still maintains the ability to accept concatenated sort criteria. This allows a single line of code to do the work, and obviates the need for multiple sorts. In that sense it was a bad example to use character "places" in a string.

Re: sort bug

2023-09-06 Thread Geoff Canyon via use-livecode
From the original email: If the function myVal encounters a run-time error (in the example if one of the items is not a number) the sort command fails silently: the script exits at that code line and the user is unaware that the sort (and the rest of the handler) were not executed. To be clear:

Re: Sort bug and also multilevel sorting

2023-09-06 Thread Neville Smythe via use-livecode
Ralph: Interesting. Your code works as you present it, sorting the given items by the sortkey function f1 which adds 1 to each item. I do get the “sorting failed” dialog. But if I try the same thing using myVal modified as you suggest, which adds the first and second items of each line of data

Re: sort bug

2023-09-02 Thread neville smythe via use-livecode
Geoff Canyon wrote (after a bravura  display of how many different ways there are to do things in LC!) : And the function sort also sorts based on a negative infinity value for errors. I'm not sure I'd consider that a bug. Hmm. I would. The sortKey function should tolerate any sort of run-time

Re: Sort bug

2023-09-01 Thread Geoff Canyon via use-livecode
With 9.6.9 on a mac and a field where the second and third items of each line are numbers: sort lines of fld 1 numeric by item 2 of each + item 3 of each -- works sort lines of fld 1 numeric by value(item 2 of each + item 3 of each) -- works sort lines of fld 1 numeric by merge("[[item 2

Re: Sort bug

2023-08-31 Thread Brian Milby via use-livecode
I just tried this in 10dp5 and the sort didn’t completely bail (it put the error value first) but it did error when including inline (as in the bug report). If I add a try, then it will stop on the throw. Not sure how much this would slow down execution though. function myVal pStr local

Re: Sort bug

2023-08-31 Thread Alex Tweedly via use-livecode
On 01/09/2023 00:37, Bob Sneidar via use-livecode wrote: The function is adding the value of two chunks together and returning the result. How does that even compute? Unless the + operator is doing something totally different here… The code said: sort lines tVariable by myVal(each) where

Re: Sort bug

2023-08-31 Thread Bob Sneidar via use-livecode
The function is adding the value of two chunks together and returning the result. How does that even compute? Unless the + operator is doing something totally different here… Bob S On Aug 31, 2023, at 3:38 PM, J. Landman Gay via use-livecode wrote: Actually, the syntax is correct. It uses

Re: Sort bug

2023-08-31 Thread J. Landman Gay via use-livecode
Actually, the syntax is correct. It uses a custom sort function. The function call includes the "each" which means it passes the correct parameter to the custom function, which then acts on it and sends the result back to the calling handler for sorting. It's a nice way to customize the

Re: Sort bug

2023-08-31 Thread Bob Sneidar via use-livecode
To be more clear, the argument to “by” needs to be a chunk statement, not a value, followed by “of each”. Your function *might* work if you returned the chunk expression instead of the actual value the chunk resolves to. But why? I am not sure what the myVal() function accomplishes. Does the

Re: Sort bug

2023-08-31 Thread Bob Sneidar via use-livecode
I think you have to append “of each”. Sort lines of tVar by item 3 of each Bob S > On Aug 30, 2023, at 9:11 PM, Neville Smythe via use-livecode > wrote: > > There is a bug in sorting a container using a function, as in > > sort lines tVariable by myVal(each) > > where the function is for

Sort bug

2023-08-30 Thread Neville Smythe via use-livecode
There is a bug in sorting a container using a function, as in sort lines tVariable by myVal(each) where the function is for example function myVal pStr return item 1 of pStr + item 2 of pStr end myval If the function myVal encounters a run-time error (in the example if one of the items is