# Sort by multiple values?

**URL:** <https://forum.elixirforum.com/t/sort-by-multiple-values/29450>\
**Category:** Questions\
**Tags:** sorting\
**Created:** [February 27, 2020, 11:09am UTC](https://forum.elixirforum.com/t/sort-by-multiple-values/29450 "2020-02-27T11:09:44Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![al2o3cr](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/al2o3cr/32/3457_2.png) [@al2o3cr](https://forum.elixirforum.com/u/al2o3cr)\
**Post date:** [August 2, 2022, 5:17pm UTC](https://forum.elixirforum.com/t/sort-by-multiple-values/29450/9 "2022-08-02T17:17:55Z")

</div>

`sort_by` is stable if EVERYTHING returns the same value:

```elixir
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.

---

_[View the full topic](https://forum.elixirforum.com/t/sort-by-multiple-values/29450)._
