You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would have expected to be able to sort the result of Timex.parse!/2 by using the Timex.compare/2 function, so I don't have to worry about whether I'm dealing with a Date or a NaiveDateTime.
iex> ["2020-01-06", "2020-01-05", "2019-12-31"]
|> Enum.map(& Timex.parse!(&1, "{ISOdate}"))
|> Enum.sort(Timex)
[~N[2020-01-06 00:00:00], ~N[2020-01-05 00:00:00], ~N[2019-12-31 00:00:00]] <-- not the right order 😢
I would have expected to be able to sort the result of
Timex.parse!/2
by using theTimex.compare/2
function, so I don't have to worry about whether I'm dealing with aDate
or aNaiveDateTime
.Expected:
Of course, this happens because
Timex.compare/2
returns-1, 0, 1
as opposed to:lt, :eg, :gt
as needed by Enum.sort/2.Any thoughts on this?
Thanks!
The text was updated successfully, but these errors were encountered: