Package: thinkmap.data.sort
This module has several functions used for aggregating and sorting collections of data
Functions
compositeSort(
var_args
, ...
)
⇒ function (
*
,
*
)
⇒
number
Composes a series of sorting functions into one sort function.
The returned function calls each individual sort until one in the series returns a non 0 value.
Parameters:
var_args :
function (
*
, *
)
⇒ number
a number of sorting functions
Returns:
function (
*
,
*
)
⇒
number
a composite sorting function
indexSort(
args
, ...
)
⇒ function (
*
,
*
)
⇒
number
Returns a sorting function that sorts elements based on their location in the passed array.
Parameters:
args :
*
the first element to compare
Returns:
function (
*
,
*
)
⇒
number
returns the newly created sorting function
A natural sorting function where if a and b are equal, they return 0, or -1 if a is null or less than b,
1 if a is greater or b is null. If both are null the function returns 0.
Parameters:
a :
*
the first element to compare
b :
*
the second element to compare
Returns:
number
0 if the two elements are equal, or -1 if a is null or less than b, 1 if a is greater or b is null. If both are null the
function returns 0.
propertySort(
property,
sort
)
⇒ function (
*
,
*
)
⇒
number
Creates a sorting function that takes a property name and optional sort and uses the values of the given property
as the key to sort on.
Parameters:
the name of the property to sort on
sort :
function (
*
, *
)
⇒ number
an optional sort to be applied on the property. If none is specified, a natural sort is used.
Returns:
function (
*
,
*
)
⇒
number
returns the newly created sorting function based on the given property
reverseSort(
sort
)
⇒ function (
*
,
*
)
⇒
number
Takes an existing sorting function, and reverses it, returning the reversed function.
Parameters:
sort :
function (
*
, *
)
⇒ number
the sort function to reverse
Returns:
function (
*
,
*
)
⇒
number
returns the new reversed sorting function