소스 검색

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

lirilsu 7 년 전
부모
커밋
cb993a6487
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      packages/table/src/util.js

+ 2 - 1
packages/table/src/util.js

@@ -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;