View Source AbsintheUtils.Helpers.Sort (absinthe_utils v0.0.2)
Generic sorting utils.
Link to this section Summary
Functions
Given an enumerable, returns a map of each element to the position in the original enumerable (zero based).
Sorts an unsorted_enumerable
based on sorted_enumerable
.
unsorted_enumerable
cannot contain duplicates and
can only contain elements from sorted_enumerable
.
Link to this section Functions
Given an enumerable, returns a map of each element to the position in the original enumerable (zero based).
examples
Examples
iex> Sort.map_enum_to_index([:a, :b, :c])
%{a: 0, b: 1, c: 2}
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
.
unsorted_enumerable
cannot contain duplicates and
can only contain elements from sorted_enumerable
.
Use mappers to specify getters for each element in the enumerable.
examples
Examples
iex> Sort.sort_alike([:b, :c, :a], [:a, :b, :c])
[:a, :b, :c]