docs: function orderBy(arr) {
      var fields = [];
      for (var _i = 1; _i < arguments.length; _i++) {
          fields[_i - 1] = arguments[_i];
      }
      var primer = function (v) { return v; };
      // Allows common primer function to be last arg in fields.
      if (is_1.isFunction(last(fields)))
          primer = (fields.pop());
      if (!fields.length) {
          var hasNumbers_1 = is_1.isNumber(first(arr)) && is_1.isNumber(last(arr));
          return arr.sort(function (a, b) {
              a = primer(a);
              b = primer(b);
              if (hasNumbers_1)
                  return a - b;
              a += '';
              b += '';
              if (a < b)
                  return -1;
              else if (a > b)
                  return 1;
              else
                  /* istanbul ignore next */
                  return 0;
          });
      }
      fields = fields.map(function (f) {
          var field = f;
          if (is_1.isString(field)) {
              field = { key: f };
              field.order = /^-/.test(f + ''); // if prefixed with - is reversed.
          }
          else if (is_1.isArray(field)) {
              field = { key: f[0] };
              field.order = f[1];
          }
          field.primer = field.primer || primer;
          field.comparator = normComparator(field.primer, field.order);
          return field;
      });
      var comparator = function (a, b) {
          var result;
          for (var _i = 0, _a = fields; _i < _a.length; _i++) {
              var field = _a[_i];
              result = field.comparator(a[field.key], b[field.key]);
              if (result !== 0)
                  break;
          }
          return result;
      };
      return arr.sort(comparator);
  }