Global.Number.Sorter (field, order)
factory to create functions for sorting objects in an array

  • Parameter String:
    name of the field each object is compared with
  • Parameter Number:
    order (ascending or descending)
  • Returns
    Function ready for use in Array.prototype.sort
Sourcecode in /home/hannes/helma/modules/core/Number.js:
24:   Number.Sorter = function(field, order) {
25:       if (!order)
26:           order = 1;
27:       return function(a, b) {
28:           return (a[field] - b[field]) * order;
29:       };
30:   }