srtr
v1.0.3
Published
A collection of annotated sort algorithms for learner users.
Downloads
5
Maintainers
Readme
srtr
srtr is a collection of sort algorithms written in JavaScript in a recursive, functional style using ES6 syntax. Code examples are heavily annotated for learners and students and the merely curious alike.
Installation
npm install srtr
Usage
srtr.quicksort(collection[, predicate]);
const srtr = require('srtr');
To sort using the default predicate (lexicographic order):
const planets = ['Kaitain', 'Geidi Prime', 'Arrakis', 'Ecaz', 'Chapterhouse'];
srtr.quicksort(planets);
srtr.bubblesort(planets);
An overriding predicate may be passed as a second parameter:
const contacts = [
{ name: 'Paul', age: 15 },
{ name: 'Shaddam', age: 75 },
{ name: 'Leto', 'age: 60 }
];
srtr.quicksort(contacts, (a, b) => a.age - b.age);
srtr.bubblesort(contact, (a, b) => {
return a.name < b.name ? -1 : a.name === b.name ? 0 : 1;
});
Testing
npm run test
Contributing
Go wild! All pull requests are welcome.
Copyright
Copyright (c) 2016 [Mark Grealish][10]. See LICENSE for details.