comb-sort
v0.1.2
Published
CombSort implementation on javascript.
Downloads
3
Maintainers
Readme
CombSort implementation on javascript.
See: https://en.wikipedia.org/wiki/Comb_sort
Install:
npm i comb-sort
or
yarn add comb-sort
Basic usage:
const data = [some...data]
const sortedData = combSort(data)
(This is mutable operation and it will change source array)
or
const sortedData = combSort(data.slice())
You can pass a custom compare function as the second argument:
const customCompare = (first, second) => {
if (
Array.isArray(first.children) &&
Array.isArray(second.children) &&
first.children.length > second.children.length
) {
return true
}
return false
}
const sortedData = combSort(data, customCompare)
Also, you can pass custom reduction value as the third argument.
const sortedData = combSort(data, customCompare, 1.8)
Be careful with playing with reduction parameter.
It can affect performance and accuracy.