Function
Basic comparision function that compares if an item is greater or less than another item
returns 1 if a > b, -1 if a < b, 0 if equal. 'null' values (null, undefined) are treated as larger values so that they're pushed to the end of the list. And compared to each other, null is equivalent to undefined. null is a problematic compare, so if null, we set to undefined. Makes the check logic simple, compact, and consistent And (null == undefined) === true, so the check later against null works for undefined and is less bytes.
int {-1,0,1}
Function
array A JS object that array that defines out what attribute names to sort on and whether it should be descenting or asending. The objects should be formatted as follows: { attribute: "attributeName-string" || attribute, descending: true|false; // Default is false. }
object The datastore object to look up item values from.
Helper function to generate the sorting function based off the list of sort attributes.
The sort function creation will look for a property on the store called 'comparatorMap'. If it exists it will look in the mapping for comparisons function for the attributes. If one is found, it will use it instead of the basic comparator, which is typically used for strings, ints, booleans, and dates. Returns the sorting function for this particular list of attributes and sorting directions.
int
Object
Object
Object
Object