sort bug

Bob Sneidar bobsneidar at iotecdigital.com
Thu Sep 7 12:24:56 EDT 2023


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 <use-livecode at lists.runrev.com> wrote:

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 and add a valid value after the bad one, the answer works as expected with the bad value being first.

Brian Milby
brian at milby7.com<mailto:brian at milby7.com>

On Sep 6, 2023, at 10:31 PM, Geoff Canyon via use-livecode <use-livecode at lists.runrev.com<mailto: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