* Used by `_.orderBy` to compare multiple properties of a value to another * and stable sort them. * * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, * specify an order of "desc" for descending or "asc" for ascending sort order * of correspo
(object, other, orders)
| 4723 | * @returns {number} Returns the sort order indicator for `object`. |
| 4724 | */ |
| 4725 | function compareMultiple(object, other, orders) { |
| 4726 | var index = -1, |
| 4727 | objCriteria = object.criteria, |
| 4728 | othCriteria = other.criteria, |
| 4729 | length = objCriteria.length, |
| 4730 | ordersLength = orders.length; |
| 4731 | |
| 4732 | while (++index < length) { |
| 4733 | var result = compareAscending(objCriteria[index], othCriteria[index]); |
| 4734 | if (result) { |
| 4735 | if (index >= ordersLength) { |
| 4736 | return result; |
| 4737 | } |
| 4738 | var order = orders[index]; |
| 4739 | return result * (order == 'desc' ? -1 : 1); |
| 4740 | } |
| 4741 | } |
| 4742 | // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications |
| 4743 | // that causes it, under certain circumstances, to provide the same value for |
| 4744 | // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 |
| 4745 | // for more details. |
| 4746 | // |
| 4747 | // This also ensures a stable sort in V8 and other engines. |
| 4748 | // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. |
| 4749 | return object.index - other.index; |
| 4750 | } |
| 4751 | |
| 4752 | /** |
| 4753 | * Creates an array that is the composition of partially applied arguments, |
no test coverage detected