| 9711 | } |
| 9712 | |
| 9713 | function baseCompare(a, b, sortKeyIndex) { |
| 9714 | var sortKey = sortKeys[sortKeyIndex]; |
| 9715 | if (sortKey) { |
| 9716 | if (sortKey !== '$key') { |
| 9717 | if (isObject(a) && '$value' in a) a = a.$value; |
| 9718 | if (isObject(b) && '$value' in b) b = b.$value; |
| 9719 | } |
| 9720 | a = isObject(a) ? getPath(a, sortKey) : a; |
| 9721 | b = isObject(b) ? getPath(b, sortKey) : b; |
| 9722 | } |
| 9723 | return a === b ? 0 : a > b ? order : -order; |
| 9724 | } |
| 9725 | |
| 9726 | // sort on a copy to avoid mutating original array |
| 9727 | return arr.slice().sort(comparator); |