viewing paste Unknown #20835 | Javascript

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12
var sort_by = function(field, reverse, primer){
 
   var key = primer ? 
       function(x) {return primer(x[field])} : 
       function(x) {return x[field]};
 
   reverse = !reverse ? 1 : -1;
 
   return function (a, b) {
       return a = key(a), b = key(b), reverse * ((a > b) - (b > a));
     } 
}
Viewed 710 times, submitted by Guest.