Table: Change sort method to match built-in Array#sort

pull/7605/head
lirilsu 2017-10-18 10:28:49 +08:00 committed by 杨奕
parent fa140dea9c
commit cb993a6487
1 changed files with 2 additions and 1 deletions

View File

@ -28,7 +28,8 @@ export const orderBy = function(array, sortKey, reverse, sortMethod) {
// sort on a copy to avoid mutating original array
return array.slice().sort(sortMethod ? function(a, b) {
return sortMethod(a, b) ? order : -order;
const result = sortMethod(a, b);
return result === 0 ? 0 : result > 0 ? order : -order;
} : function(a, b) {
if (sortKey !== '$key') {
if (isObject(a) && '$value' in a) a = a.$value;