On Mon, May 14, 2018 at 4:18 PM, Hobart Spitz <[email protected]> wrote:

> It would be a very, very good thing to work just like the comparison
> operators.  It should intuituvely apply the same logic that takes place
> with comparison operators.  That is what any REXX programmer would expect.
>
> Why introduce new "surprises"?
>

Ah, but which comparison operators? There are strict and non-strict
operators for a reason, because there are situations where the difference
is important. Sort IS using comparison operator behavior, but it is the
strict operators by default, but the programmer has complete control over
how things are done if the default is now what you want.

Switch the behavior because of the data contained in any give pair of lines
would give at best an unreliable sort...it might even in some cases in a
sort that can never complete because the order is not defined. Consider for
example, trying to sort the following bits of hex data: "0010", "00d0",
"00e0". Using the non-strict comparison operators, "0010" is < "00d0",
"00d0" is < "00e0", but "0010" is > than "00e0" because both happen to be
numeric data. Under those rules, there is no definable sort order for the
data items.

Rick



>
> On Mon, 14 May 2018, 4:10 pm Rick McGuire, <[email protected]> wrote:
>
>> That would be a very bad thing. If the data in the array was a mix of
>> numeric and non-numeric values, then some comparisons would be performed
>> one way, others differently. You would never be able to get a reliable sort
>> result. It would be a little bit like the comparison
>>
>> if '0000' = '00e0' then say "Hi"
>>
>> giving a true result. Because the "=" operator is used rather than '==',
>> the numeric comparison got used because "00e0" is a valid numeric
>> representation for zero. In a sort, a lot more comparisons need to be
>> performed, so it is important that each one be done using the same set of
>> rules, not changing suddenly because of some quirk in the data.
>>
>> Again, the sortWith method and the Comparator class were designed to give
>> you the flexibility to decide precisely how the comparisons get performed
>> if the default does not meet your requirements.
>>
>> Rick
>>
>> Rick
>>
>> On Mon, May 14, 2018 at 4:01 PM, Leslie Turriff <[email protected]>
>> wrote:
>>
>>> On 2018-05-14 14:39:36 Rick McGuire wrote:
>>> > Frankly, a request for a NumericColumnComparator would fall pretty far
>>> down
>>> > the list of things I might work on, but once you have written one
>>> yourself,
>>> > you can reuse it over and over again in as many places you want.
>>>
>>>         What I was thinking was that the built-in sort comparators ought
>>> to notice
>>> when the values provided are numeric (when added to 0) and do the
>>> numeric
>>> comparison internally.
>>>
>>> ------------------------------------------------------------
>>> ------------------
>>> Check out the vibrant tech community on one of the world's most
>>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>>> _______________________________________________
>>> Oorexx-devel mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/oorexx-devel
>>>
>>
>> ------------------------------------------------------------
>> ------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot______
>> _________________________________________
>> Oorexx-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/oorexx-devel
>>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Oorexx-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/oorexx-devel
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to