sortBy()

Shallow copies and sorts an array given specific criteria.

This function is valid in v2.0.0 to v2.12.0. This function has been downloaded 12 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 requires the following functions which are included automatically:

  • compare()
    Simple compare function typically use in sorting.
  • typeOf()
    Either gets the type of a value or adds a constructor registering its custom type name.