Commit cb993a64 authored by lirilsu's avatar lirilsu Committed by 杨奕

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

parent fa140dea
...@@ -28,7 +28,8 @@ export const orderBy = function(array, sortKey, reverse, sortMethod) { ...@@ -28,7 +28,8 @@ export const orderBy = function(array, sortKey, reverse, sortMethod) {
// sort on a copy to avoid mutating original array // sort on a copy to avoid mutating original array
return array.slice().sort(sortMethod ? function(a, b) { 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) { } : function(a, b) {
if (sortKey !== '$key') { if (sortKey !== '$key') {
if (isObject(a) && '$value' in a) a = a.$value; if (isObject(a) && '$value' in a) a = a.$value;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment