MCPcopy
hub / github.com/lodash/lodash / compareAscending

Function compareAscending

lodash.js:4681–4709  ·  view source on GitHub ↗

* Compares values to sort them in ascending order. * * @private * @param {*} value The value to compare. * @param {*} other The other value to compare. * @returns {number} Returns the sort order indicator for `value`.

(value, other)

Source from the content-addressed store, hash-verified

4679 * @returns {number} Returns the sort order indicator for `value`.
4680 */
4681 function compareAscending(value, other) {
4682 if (value !== other) {
4683 var valIsDefined = value !== undefined,
4684 valIsNull = value === null,
4685 valIsReflexive = value === value,
4686 valIsSymbol = isSymbol(value);
4687
4688 var othIsDefined = other !== undefined,
4689 othIsNull = other === null,
4690 othIsReflexive = other === other,
4691 othIsSymbol = isSymbol(other);
4692
4693 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
4694 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
4695 (valIsNull && othIsDefined && othIsReflexive) ||
4696 (!valIsDefined && othIsReflexive) ||
4697 !valIsReflexive) {
4698 return 1;
4699 }
4700 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
4701 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
4702 (othIsNull && valIsDefined && valIsReflexive) ||
4703 (!othIsDefined && valIsReflexive) ||
4704 !othIsReflexive) {
4705 return -1;
4706 }
4707 }
4708 return 0;
4709 }
4710
4711 /**
4712 * Used by `_.orderBy` to compare multiple properties of a value to another

Callers 1

compareMultipleFunction · 0.85

Calls 1

isSymbolFunction · 0.85

Tested by

no test coverage detected