sort-anythingdeprecated

Sort arrays in a functional programming way. A simple & small integration.

Usage no npm install needed!

<script type="module">
  import sortAnything from 'https://cdn.skypack.dev/sort-anything';
</script>

README

Sort anything 🗃 (Archived)

This (short-lived) library was merely an experiment. It's currently archived in favour of snovakovic/fast-sort. His sorting library is easy to use, supports typescript and is blazing fast!

npm i sort-anything

Sort arrays in a functional programming way. A simple & small integration.

Motivation

I wanted to create a way to sort arrays that's close to "functional programming" and has a TINY footprint!

Meet the family

Usage

Sorting on a single prop:

import { sort } from 'sort-anything'

const array = [{ id: 3 }, { id: 1 }, { id: 2 }]

sort(array).by('id', 'asc') === [{ id: 1 }, { id: 2 }, { id: 3 }]

Sorting on multiple props:

import { sort } from 'sort-anything'

const array = [
  { id: 3, tag: 'a' },
  { id: 1, tag: 'b' },
  { id: 1, tag: 'a' },
  { id: 2, tag: 'a' },
]

sort(array).by(['id', 'asc'], ['tag', 'asc']) ===
  [
    { id: 1, tag: 'a' },
    { id: 1, tag: 'b' },
    { id: 2, tag: 'a' },
    { id: 3, tag: 'a' },
  ]