sort

A helpful utility to sort array data in your stores. If array items are string or numbers a default compare function which uses difference of 2 items, you can provide your own comparator or whole sort function as well.

Demo

Array data:
[1,5,6,2,9,6,7,8]
				
Sorted data:
[1,2,5,6,6,7,8,9]
				

Usage

<script lang="ts">
import { sort } from "svelte-legos";
import { writable } from "svelte/store";

const data = writable([1, 5, 6, 2, 9, 6, 7, 8]);
const sorted = sort(data);
</script>