dist/tree-tools.js
function sortBy(tree, propertyName) {
    var _this = this;

    // It is needed an array structure to sort.
    if (!_.isArray(tree)) tree = [tree];
    tree.forEach(function (item) {
      return _(item).keys().forEach(function (key) {
        if (_.isArray(item[key])) item[key] = _this.sortBy(item[key], propertyName);
      });
    });
    return _.sortBy(tree, propertyName);
  }
function sortBy(tree, propertyName) {
    var _this = this;

    // It is needed an array structure to sort.
    if (!_.isArray(tree)) tree = [tree];
    tree.forEach(function (item) {
      return _(item).keys().forEach(function (key) {
        if (_.isArray(item[key])) item[key] = _this.sortBy(item[key], propertyName);
      });
    });
    return _.sortBy(tree, propertyName);
  }
function sortBy ( tree , propertyName ) { var _this = this ; // It is needed an array structure to sort. if ( ! _ . isArray ( tree ) ) tree = [ tree ] ; tree . forEach ( function ( item ) { return _ ( item ) . keys ( ) . forEach ( function ( key ) { if ( _ . isArray ( item [ key ] ) ) item [ key ] = _this . sortBy ( item [ key ] , propertyName ) ; } ) ; } ) ; return _ . sortBy ( tree , propertyName ) ; }
Utility function to sort tree by specific property or an array of properties
@param {array} tree The tree structure to sort
@param {array|string} propertyName Property names to sort the tree
@return {array} An array sorted by propertyName
Utility function to sort tree by specific property or an array of properties