AbsintheUtils.Helpers.Sorting (absinthe_utils v0.0.1-main-d255e08b6c32fe6449757ed94e6abba8bb9a31e7)
View SourceGeneric sorting utils.
Summary
Functions
Sorts an unsorted_enumerable
based on sorted_enumerable
.
Use mappers to specify getters for each element in the enumerable,
for example retrieving the id of a struct.
Functions
Sorts an unsorted_enumerable
based on sorted_enumerable
.
Use mappers to specify getters for each element in the enumerable,
for example retrieving the id of a struct.
Examples
iex> Sorting.sort_alike([:b, :c, :a], [:a, :b, :c])
[:a, :b, :c]
iex> Sorting.sort_alike([%{id: 1}, %{id: 2}], [2, 1], & &1.id)
[%{id: 2}, %{id: 1}]