View Source AbsintheUtils.Helpers.Sorting (absinthe_utils v0.0.8)
Generic sorting utils.
Link to this section 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.
Link to this section Functions
Link to this function
sort_alike(unsorted_enumerable, sorted_enumerable, unsorted_enumerable_mapper \\ & &1, sorted_enumerable_mapper \\ & &1)
View SourceSorts 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
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}]