Consumes all values from an (async)iterable and returns them sorted by the passed sort function.
import sort from 'it-sort'import all from 'it-all'const sorter = (a, b) => { return a.localeCompare(b)}// This can also be an iterator, generator, etcconst values = ['foo', 'bar']const arr = all(sort(values, sorter))console.info(arr) // 'bar', 'foo' Copy
import sort from 'it-sort'import all from 'it-all'const sorter = (a, b) => { return a.localeCompare(b)}// This can also be an iterator, generator, etcconst values = ['foo', 'bar']const arr = all(sort(values, sorter))console.info(arr) // 'bar', 'foo'
Async sources must be awaited:
import sort from 'it-sort'import all from 'it-all'const sorter = (a, b) => { return a.localeCompare(b)}const values = async function * () { yield * ['foo', 'bar']}const arr = await all(sort(values, sorter))console.info(arr) // 'bar', 'foo' Copy
import sort from 'it-sort'import all from 'it-all'const sorter = (a, b) => { return a.localeCompare(b)}const values = async function * () { yield * ['foo', 'bar']}const arr = await all(sort(values, sorter))console.info(arr) // 'bar', 'foo'
Consumes all values from an (async)iterable and returns them sorted by the passed sort function.
Example
Async sources must be awaited: