[erlang-questions] map elements in defined order

Richard Carlsson carlsson.richard@REDACTED
Fri Oct 27 21:36:58 CEST 2017

```2017-10-27 17:45 GMT+02:00 Sverker Eriksson <sverker.eriksson@REDACTED>
>
>
> How would you order  #{1 => x, 1.0 => y} and #{1 => y, 1.0 => x}
> if you can't order 1 and 1.0?
>

As long as we're talking about the arithmetic term order (<, >, ==), I
don't see why they would need to be. Look at tuples:

{1, 1.0} < {1.0, 1}.
false
{1, 1.0} > {1.0, 1}.
false
{1, 1.0} == {1.0, 1}.
true
{1, 1.0} =:= {1.0, 1}.
false

Maps ought to behave analogously, in the arithmetic ordering. The weirdness
comes from enforcing strict ordering in the middle of the arithmetic one.
The current ordering rule for maps should only be used in the strict
ordering (the suggested :<), where it would also apply to tuples: {1, 1.0}
:< {1.0, 1}.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20171027/3b67eb7e/attachment.htm>
```