nif_sorter v0.2.0 NifSorter View Source
NIF replacement for Enum.sort/1 for typed list of strings/numbers
Link to this section Summary
Functions
Sort typed list of floats in ascending order
Sort typed list of integers in ascending order
Sort typed list of strings/integers/floats in ascending order
Sort typed list of strings alphabetically in ascending order
Link to this section Types
Link to this section Functions
Sort typed list of floats in ascending order
Examples
iex> NifSorter.float_sort([2.31, 2.07, 1.2, -10.4])
[-10.4, 1.2, 2.07, 2.31]
iex> NifSorter.int_sort([2, 1.14])
(ArgumentError) argument error
Sort typed list of integers in ascending order
Works for integers in range -9223372036854775808..9223372036854775807
Examples
iex> NifSorter.int_sort([2, 3, 1])
[1, 2, 3]
iex> NifSorter.int_sort([2, 1.14])
(ArgumentError) argument error
Sort typed list of strings/integers/floats in ascending order
This methods just auto-detects list type by first item. List still should be strictly typed.
Examples
iex> NifSorter.sort(["xir", "i", "el"])
["el", "i", "xir"]
iex> NifSorter.sort([2, 3, 1])
[1, 2, 3]
iex> NifSorter.sort([2.31, 2.07, 1.2, -10.4])
[-10.4, 1.2, 2.07, 2.31]
iex> NifSorter.sort([1, 2.2])
(ArgumentError) argument error
Sort typed list of strings alphabetically in ascending order
Examples
iex> NifSorter.str_sort(["xir", "i", "el"])
["el", "i", "xir"]
iex> NifSorter.str_sort(["aaa", 123])
(ArgumentError) argument error