sort_by is stable if EVERYTHING returns the same value:
iex(1)> [%{color: "yellow", name: "potato"}, %{color: "red", name: "apple"}] |> Enum.reverse() |> Enum.sort_by(&{!&1.color, !&1.name})
[%{color: "red", name: "apple"}, %{color: "yellow", name: "potato"}]
This should have returned the map with “yellow” first (like in your second example) if it was meaningfully sorting.






















