byString sortable

Description

The byString sortable, as the name explain, is the sortable to sort the string type

Example

Standard example

//js or ts file
import { byString } from 'sort-es'

const unsorted = ["xxx", "bbbb", "zzz", "cccc", "aaa"];
const sorted = unsorted.sort(byString());

console.log(sorted); //(5) ["aaa", "bbbb", "cccc", "xxx", "zzz"]

Sort descending

//js or ts file
import { byString } from 'sort-es'

const unsorted = ["xxx", "bbbb", "zzz", "cccc", "aaa"];
const sorted = unsorted.sort(byString({desc : true}));

console.log(sorted); //(5) ["zzz", "xxx", "cccc", "bbbb","aaa"]

Sort as lowerCase

//js or ts file
import { byString } from 'sort-es'

const unsorted =  ["AAA", "aaB", "ccA", "cccc", "aAc"];
const sorted = unsorted.sort(byString({ lowercase: true }));

console.log(sorted); //(5) ["AAA", "aaB", "aAc", "ccA", "cccc"];