sortBy()

Shallow copies and sorts an array given specific criteria.

This function is valid in v2.13.3 to v2.24.3. This function has been downloaded 60 times.

Parameters

{Array} array
Array to be sorted.
{string|Array.|Function} criteria
Criteria by which a shallow copy of array will be sorted. If a string or an array is supplied it will be used as the path to each individual array element that will be keyed off of to do the sort.
{Function=} opt_comparer Optional, Default:YourJS.compare
Comparison function used to compare each array element criteria.

Returns

{Array}
A shallow copy of the array sorted according to the specified criteria and comparison function.

Required Functions

This function directly requires the following functions which are included automatically:

  • compare()
    Simple compare function typically use in sorting.
  • has()
    Every object descended from Object inherits the hasOwnProperty method. This method can be used to determine whether an object has the specified property as a direct property of that object; unlike the in operator, this method does not check down the object's prototype chain.