sort

sorts files in the list

void sort(object rule);
ruleobjectan object with parameters for sorting

Example

vault.data.sort({
    rule: function(a, b) {
        return a.size < b.size ? 1 : -1;
    }
});

Related samples

Details

The rule object has the following parameters:

  • by - (function) a sorting function that contains the necessary rules for sorting
  • dir - (string) optional, the direction of sorting ("asc" or "desc")

the function must have two parameters, it will be called for each pair of adjacent values and will return a number (-1 or 1):

  • 1 - an object with the first value in pair must go before the second one;
  • -1 - the second object goes before the first one.
See also
Back to top