Here is a proposal I am satisfied with: https://github.com/elixir-lang/elixir/pull/9426
It solves sorting but it doesn't solve getting the earliest/latest. There will be another PR to address those. The idea is to provide a general framework to address these limitations, as it will also be useful for libraries like Decimal. *José Valim* www.plataformatec.com.br Skype: jv.ptec Founder and Director of R&D On Fri, Oct 18, 2019 at 9:39 AM Dmitry Belyaev <be.dmi...@gmail.com> wrote: > I suppose it's reasonable to have a defined ordering within a particular > class e.g. number class includes integers and floats, and have some > (possibly undefined) ordering between classes. This basically is the same > as Erlang term order, but for every struct we could define its own class or > in some special cases a few structures would map to the same ordering class. > > Then to make Erlang term ordering to work for us we can build a tuple > {{class, class_ordering_term}, original_term}, e.g {{Number, 1}, 1}, > {{DateTime, epoch_integer}, %DateTime{...}}, {{Atom, nil}, nil}. > > On 18 October 2019 9:27:54 am AEDT, "José Valim" < > jose.va...@plataformatec.com.br> wrote: >> >> >> >>> I do wonder about your follow-up: Why would it not work for integers? >>> (and float and decimals)? At least as long as we are comparing collections >>> of *only* integers or *only* floats or *only* decimals, the result >>> would be sensible. >>> >> If we want to make Ordered work between them, well, then it becomes a bit >>> more difficult: In that case we probably would need to 'upcast' all of them >>> into some kind of more general tuples-of-integers-and-strings form. >>> >> >> Exactly. That's the problem and at a quick glance I could not find a >> solution. I am glad to be proven wrong though! >> >> >> > -- > Kind regards, > Dmitry Belyaev > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2BDeHLEbeKjzaoiEP58GALq1epCKcL0e7ELhiL4dzdUnw%40mail.gmail.com.