sort bug
Bob Sneidar
bobsneidar at iotecdigital.com
Thu Sep 7 11:19:19 EDT 2023
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 <use-livecode at lists.runrev.com> wrote:
>
> 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: the above is NOT what I'm seeing. Mark W says in the bug
> report:
>
> The 'sort ... by ...' command has always allowed the by expression to be
> fault tolerant - if evaluating it generates a runtime error then the sort
> key for that element is just taken to be the original element.
>
> And that is what I'm seeing. For example, this code does not exit -- it
> displays the answer dialog as if nothing out of the ordinary has happened:
>
> on mouseUp
> sort lines of fld 1 numeric by sortVal(each)
> answer "done"
> end mouseUp
>
> function sortVal S
> return item 2 of S + item 3 of S
> end sortVal
>
> It seems to be sorting as Mark described: when the function fails, the
> whole line is used for the sort. And that "fallback to the whole value
> needs better documentation, and could lead to some truly dismal debugging
> situations, but it doesn't seem like a bug to me.
>
> The original report, if I were able to replicate it, would clearly be a bug.
More information about the use-livecode
mailing list