Skip to content

Instantly share code, notes, and snippets.

View Rosencrantz's full-sized avatar

Steve Haffenden Rosencrantz

View GitHub Profile
@Rosencrantz
Rosencrantz / heapsort.js
Created January 14, 2012 12:37
Heapsort example in javascript (i think)
var list = [9,1,7,3,4,2,8,0,5,6];
function chunk(list) {
var chunks = [];
for(var i=0; i<list.length; i++) {
if(list.length % 2 == 1 && i+1 == list.length) {
chunks.push(list[i]);
} else {
if(i % 2 == 0) {
chunks.push(Math.max(list[i], list[i+1]));