Binary, List and Tuple Inequalities (Paradox?)
Valentin Micic
v@REDACTED
Sun Oct 27 13:16:11 CET 2019
Thanks for the replies… unsatisfactory as they me have been :-)
Kind regards
V/
> On 25 Oct 2019, at 17:43, Fred Hebert <mononcqc@REDACTED> wrote:
>
>
>
> On Fri, Oct 25, 2019 at 11:35 AM Dmitry Belyaev <be.dmitry@REDACTED <mailto:be.dmitry@REDACTED>> wrote:
> To me alphabetical ordering of lists (as legacy string representation) and binaries (as modern string representation) is natural, so it is expected that "aa" < "b" < "bb".
>
> As a general note, this is only true to the extent that you don't care that "ZOOM" is < than "apple" in this dictionary. It is anything but natural, I would say it's probably more "accidental". Actual string sorting tends to rely on a Unicode collation algorithm (a part of the spec that is still missing in the stdlib), since even string normalization won't be enough to ensure things are done safely with regards to human expectations. At this point only libraries such as ux <https://github.com/erlang-unicode/ux> support it well.
>
> Most of the orderings we have right now are often arbitrary and can have surprising sides to them. At this point for most data structures the important thing is not that the ordering is correct, but that at least one exists at all; this allows the creation of a bunch of data structures (usually trees and variants) to work on all data types, mixed or not. All atoms are smaller than all strings, even if atoms have a string component to them, for example.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20191027/fef50af9/attachment.htm>
More information about the erlang-questions
mailing list