Socket
Socket
Sign inDemoInstall

comb-sort

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    comb-sort

CombSort implementation on javascript.


Version published
Maintainers
1
Install size
9.30 kB
Created

Readme

Source

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.

Keywords

FAQs

Last updated on 28 Aug 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc