map.sort(function(a, b){ for (var i=1; i--; ) { if (a[i] < b[i]) return -1; else if (a[i] > b[i]) return 1; } return 0; })