0.1.0 • Published 11 years ago
bogobogo v0.1.0
bogobogo
Simple implementation of Bogobogosort
NOTE: For obvious reasons, there isn't a clear document describing how Bogobogosort works. This implmentation includes both popular versions with the default being the slower one.
Slow (default)
- Get first
n(nstarts at 2) items of list. - Shuffle
nitems (uses Fisher-Yates shuffle). - If
nitems are not sorted, setnback to 2. If they are sorted, thennincreases by one unlessnalready includes the whole array, in which case, the sort is finished. - Return to step 1.
"Fast"
- Get first
n(nstarts at 2) items of list. - Shuffle
nitems (uses Fisher-Yates shuffle). - If
nitems are not sorted, return to step 2. - If
nincludes who array then sort is finished, if not, increasenby one and return to step 1.
Install
$ npm install --save bogobogoUsage
var bogobogo = require('bogobogo');
bogobogo.create([66, 22, 3, 5, 1, 19]).then(function(result){
console.log(result);
}).start();License
MIT © Falkirks