Browse Source

Merge pull request #4656 from wenzhixin/fix/4314

Fixed sortStable cannot work bug
Dustin Utecht 6 years ago
parent
commit
b0b179dc63
2 changed files with 5 additions and 4 deletions
  1. 2 1
      src/bootstrap-table.js
  2. 3 3
      src/utils/index.js

+ 2 - 1
src/bootstrap-table.js

@@ -422,7 +422,8 @@ class BootstrapTable {
             return order * value
           }
 
-          return Utils.sort(aa, bb, order, this.options.sortStable)
+          return Utils.sort(aa, bb, order, this.options.sortStable,
+            a._position, b._position)
         })
       }
 

+ 3 - 3
src/utils/index.js

@@ -271,7 +271,7 @@ export default {
     return data
   },
 
-  sort (a, b, order, sortStable) {
+  sort (a, b, order, sortStable, aPosition, bPosition) {
     if (a === undefined || a === null) {
       a = ''
     }
@@ -280,8 +280,8 @@ export default {
     }
 
     if (sortStable && a === b) {
-      a = a._position
-      b = b._position
+      a = aPosition
+      b = bPosition
     }
 
     // If both values are numeric, do a numeric comparison