A set of useful comparators compatible with
The following naming convention is used:
For example: `stringComparator2Asc` means that comparator function takes 2 string objects and compares it in ascending order.
Can be used as
_.sortBy().The following naming convention is used:
<dataType>Comparator<Arguments count: 1 or 2><Comparing direction: 'Asc' or 'Desc'>.For example: `stringComparator2Asc` means that comparator function takes 2 string objects and compares it in ascending order.
Can be used as
comparator in Backbone.Collection.Members
-
<static> stringComparator1
-
Methods
-
<static> booleanComparator2Asc(a, b)
-
Parameters:
Name Type Description aBoolean Argument A. bBoolean Argument B. Returns:
Result as follows:-1- if A < B.0- if A == B.1- if A > B.
- Type
- Number
-
<static> booleanComparator2Desc(a, b)
-
Parameters:
Name Type Description aBoolean Argument A. bBoolean Argument B. Returns:
Result as follows:-1- if A < B.0- if A == B.1- if A > B.
- Type
- Number
-
<static> dateComparator2Asc(a, b)
-
Parameters:
Name Type Description aDate | String | moment Argument A. Javascript Date, date string in ISO8691 or momentJS date.bDate | String | moment Argument B. Javascript Date, date string in ISO8691 or momentJS date.Returns:
Result as follows:-1- if A < B.0- if A == B.1- if A > B.
- Type
- Number
-
<static> dateComparator2Desc(a, b)
-
Parameters:
Name Type Description aDate | String | moment Argument A. Javascript Date, date string in ISO8691 or momentJS date.bDate | String | moment Argument B. Javascript Date, date string in ISO8691 or momentJS date.Returns:
Result as follows:-1- if A < B.0- if A == B.1- if A > B.
- Type
- Number
-
<static> durationComparator2Asc(a, a)
-
Parameters:
Name Type Description aString | Object Argument A. An ISO8601 duration string ('P1Y2M3DT4H5M6S'), a string separated by colons like '7.23:59:59.999' or MomentJS object like { seconds: 2, minutes: 2, hours: 2, days: 2, weeks: 2, months: 2, years: 2 }.aString | Object Argument B. An ISO8601 duration string ('P1Y2M3DT4H5M6S'), a string separated by colons like '7.23:59:59.999' or MomentJS object like { seconds: 2, minutes: 2, hours: 2, days: 2, weeks: 2, months: 2, years: 2 }.Returns:
Result as follows:-1- if A < B.0- if A == B.1- if A > B.
- Type
- Number
-
<static> durationComparator2Desc(a, a)
-
Parameters:
Name Type Description aString | Object Argument A. An ISO8601 duration string ('P1Y2M3DT4H5M6S'), a string separated by colons like '7.23:59:59.999' or MomentJS object like { seconds: 2, minutes: 2, hours: 2, days: 2, weeks: 2, months: 2, years: 2 }.aString | Object Argument B. An ISO8601 duration string ('P1Y2M3DT4H5M6S'), a string separated by colons like '7.23:59:59.999' or MomentJS object like { seconds: 2, minutes: 2, hours: 2, days: 2, weeks: 2, months: 2, years: 2 }.Returns:
Result as follows:-1- if A < B.0- if A == B.1- if A > B.
- Type
- Number
-
<static> emptyComparator()
-
Empty comparator.
Returns:
Always 0 (means equals).- Type
- Number
-
<static> getComparatorByDataType(dataType, sorting)
-
Method returns comparator function based on type name.
Parameters:
Name Type Description dataTypeString Data type as in core.meta.objectPropertyTypes.sortingString What sorting do we need? Options: 'asc''desc'
Returns:
Comparator function.- Type
- function
-
<static> numberComparator2Asc(a, b)
-
Parameters:
Name Type Description aNumber Argument A. bNumber Argument B. Returns:
Result as follows:-1- if A < B.0- if A == B.1- if A > B.
- Type
- Number
-
<static> numberComparator2Desc(a, b)
-
Parameters:
Name Type Description aNumber Argument A. bNumber Argument B. Returns:
Result as follows:-1- if A < B.0- if A == B.1- if A > B.
- Type
- Number
-
<static> referenceComparator2Asc(a, b)
-
Method to compare objects by it's
nameproperty.Parameters:
Name Type Description aObject Argument A. bObject Argument B. Returns:
Result as follows:-1- if A < B.0- if A == B.1- if A > B.
- Type
- Number
-
<static> referenceComparator2Desc(a, b)
-
Method to compare objects by it's
nameproperty.Parameters:
Name Type Description aObject Argument A. bObject Argument B. Returns:
Result as follows:-1- if A < B.0- if A == B.1- if A > B.
- Type
- Number
-
<static> stringComparator2Asc(a, b)
-
Parameters:
Name Type Description aString Argument A. bString Argument B. Returns:
Result as follows:-1- if A < B.0- if A == B.1- if A > B.
- Type
- Number
-
<static> stringComparator2Desc(a, b)
-
Parameters:
Name Type Description aString Argument A. bString Argument B. Returns:
Result as follows:-1- if A < B.0- if A == B.1- if A > B.
- Type
- Number