code: function makeSortfunc(key, desc) {
    return function(a, b) {
      var akey = key(a), bkey = key(b);
      var result = akey < bkey ? -1 : akey > bkey ? +1 : 0;
      return desc ? -result : result;
    };
  }
docs: Create a sort function suitable for passing to `Array#sort`.