https://github.com/alexeyraspopov/heapsort
A JavaScript Heapsort Algorithm Implementation
https://github.com/alexeyraspopov/heapsort
Last synced: about 1 month ago
JSON representation
A JavaScript Heapsort Algorithm Implementation
- Host: GitHub
- URL: https://github.com/alexeyraspopov/heapsort
- Owner: alexeyraspopov
- License: mit
- Created: 2015-01-11T16:17:46.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2021-07-09T12:51:26.000Z (almost 4 years ago)
- Last Synced: 2025-03-18T03:12:30.890Z (about 2 months ago)
- Language: JavaScript
- Size: 14.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Heapsort
A JavaScript Heapsort implementation with `O(nlog n)` complexity.
## ESM Package
Starting from `v0.2.0` this package fully moved to ES Modules and ES2015 code. This means no more build step before publishing to NPM.
Ideally you shouldn't spot any difference, but in case you face any issues, see [this useful article](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#how-can-i-move-my-commonjs-project-to-esm).
You can also downgrade to `v0.1.2` to use all the same functionality, precompiled to ES5.
## Install
npm install heapsort
## API
import heapsort from 'heapsort';
heapsort(array[, comparator]);
If you need to save the original array you should pass a copy, because heapsort will mutate it.
Comparator is a function which compares two elements and returns 0, 1 or -1. [Read more about comparator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
## License
MIT License (c) Alexey Raspopov