Current behavior:
iex(3)> [~D[2017-01-04], ~D[2017-04-03], ~D[2017-01-05]] |> Enum.sort
[~D[2017-04-03], ~D[2017-01-04], ~D[2017-01-05]]
Proposed:
iex(3)> [~D[2017-01-04], ~D[2017-04-03], ~D[2017-01-05]] |> Enum.sort
[~D[2017-01-04], ~D[2017-01-05], ~D[2017-04-03]]
What I'm currently doing is:
iex(4)> [~D[2017-01-04], ~D[2017-04-03], ~D[2017-01-05]] |> Enum.map(&(Date.to_erl/1)) |> Enum.sort |> Enum.map(&(Date.from_erl!/1))
[~D[2017-01-04], ~D[2017-01-05], ~D[2017-04-03]]
which is working great, but would be cool to have Enum.sort work on Date types too.
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/5cb8a9f9-ee03-497e-87d6-7bd9633b2f78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Probably easier to use `Enum.sort_by(dates, &DateTime.to_unix/1)`, no?Paul
On Fri, Jan 20, 2017 at 1:39 PM, Josh Crews <crews...@gmail.com> wrote:
Current behavior:
iex(3)> [~D[2017-01-04], ~D[2017-04-03], ~D[2017-01-05]] |> Enum.sort
[~D[2017-04-03], ~D[2017-01-04], ~D[2017-01-05]]
Proposed:
iex(3)> [~D[2017-01-04], ~D[2017-04-03], ~D[2017-01-05]] |> Enum.sort
[~D[2017-01-04], ~D[2017-01-05], ~D[2017-04-03]]
What I'm currently doing is:
iex(4)> [~D[2017-01-04], ~D[2017-04-03], ~D[2017-01-05]] |> Enum.map(&(Date.to_erl/1)) |> Enum.sort |> Enum.map(&(Date.from_erl!/1))
[~D[2017-01-04], ~D[2017-01-05], ~D[2017-04-03]]
which is working great, but would be cool to have Enum.sort work on Date types too.
--
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-co...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/8a996168-b548-4730-a2a6-baa38a88d712%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/8a996168-b548-4730-a2a6-baa38a88d712%40googlegroups.com.