MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / compareMultiple

Function compareMultiple

lib/web/jshint.js:1941–1965  ·  view source on GitHub ↗

* Used by `_.sortByOrder` to compare multiple properties of each element * in a collection and stable sort them in the following order: * * If `orders` is unspecified, sort in ascending order for all properties. * Otherwise, for each property, sort in ascending order if its corresponding

(object, other, orders)

Source from the content-addressed store, hash-verified

1939 * @returns {number} Returns the sort order indicator for `object`.
1940 */
1941 function compareMultiple(object, other, orders) {
1942 var index = -1,
1943 objCriteria = object.criteria,
1944 othCriteria = other.criteria,
1945 length = objCriteria.length,
1946 ordersLength = orders.length;
1947
1948 while (++index < length) {
1949 var result = baseCompareAscending(objCriteria[index], othCriteria[index]);
1950 if (result) {
1951 if (index >= ordersLength) {
1952 return result;
1953 }
1954 return result * (orders[index] ? 1 : -1);
1955 }
1956 }
1957 // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
1958 // that causes it, under certain circumstances, to provide the same value for
1959 // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
1960 // for more details.
1961 //
1962 // This also ensures a stable sort in V8 and other engines.
1963 // See https://code.google.com/p/v8/issues/detail?id=90 for more details.
1964 return object.index - other.index;
1965 }
1966
1967 /**
1968 * Used by `_.deburr` to convert latin-1 supplementary letters to basic latin letters.

Callers 1

baseSortByOrderFunction · 0.85

Calls 1

baseCompareAscendingFunction · 0.85

Tested by

no test coverage detected