pulsar/spec/fixtures/sample.js
Corey Johnson & Nathan Sobo 90faddf9f1 Refactor all buffer manipulation to use Buffer.change
Change takes a range and a string and replaces the range with the
string, then emits a change event with the range of text that was
changed, the range of text occupied by the new string, and the string
itself. This can be used to implement backspace, insert, as well as
various cut and paste manipulations.
2012-01-25 17:59:15 -08:00

13 lines
408 B
JavaScript

var quicksort = function () {
var sort = function(items) {
if (items.length <= 1) return items;
var pivot = items.shift(), current, left = [], right = [];
while(items.length > 0) {
current = items.shift();
current < pivot ? left.push(current) : right.push(current);
}
return sort(left).concat(pivot).concat(sort(right));
};
return sort(Array.apply(this, arguments));
};