I have a list of NaiveDateTimes and I want to get the most recent one. What's the easiest way to sort a list of DateTimes / NaiveDateTimes?
I know it's unsafe to use Elixir's standard sorting rules, since it compares terms structurally rather than looking at the meaning of the dates:
# UNSAFE / returns entries in incorrect order:
[~N[2020-02-29 10:00:01], ~N[2020-03-11 10:20:00], ~N[2020-03-15 10:00:00]] |> Enum.sort
# => [~N[2020-03-11 10:20:00], ~N[2020-03-15 10:00:00], ~N[2020-02-29 10:00:01]]