nif_sorter
NIF faster sort typed list of strings/integers/floats (with C++ std::sort)
Installation
Add to deps in mix.exs:
{:nif_sorter, "~> 0.2.2"}Works on Elixir 1.7+
Usage
NifSorter.sort(["xir", "i", "el"])
# ["el", "i", "xir"]
NifSorter.sort([2, 3, 1])
# [1, 2, 3]
NifSorter.sort([2.31, 2.07, 1.2, -10.4])
# [-10.4, 1.2, 2.07, 2.31]
NifSorter.sort([1, 2.2])
# (ArgumentError) argument errorRestrictions
-
Works only on strictly typed lists.
Supported types:
string,integer,float. Can't mix types in list likeNifSorter.sort(["aa", 12, 1.33]) -
Sort by integers works for integers in range
-9223372036854775808 .. 9223372036854775807
Performance
- See benchmarks for
- Memory usage is more efficient.
- Sort list of numbers is 2-3x faster.
- Sort list of strings wins by speed on big data (~30% faster on 100K).
Commands
-
Interactive shell:
$ make cli -
Run benchmarks:
$ make bench $ make bench/fast -
Run tests:
$ make test