Skip to content
Permalink
Browse files

fix(MdTable): improve sort function on table for numbered columns (#1353

)

fix #1349
  • Loading branch information...
VdustR authored and marcosmoura committed Dec 27, 2017
1 parent 567e9a7 commit 18bb96c9694d5e760eec35d4242f56efe0a6828f
Showing with 9 additions and 3 deletions.
  1. +9 −3 src/components/MdTable/MdTable.vue
@@ -105,12 +105,18 @@
const sortBy = this.MdTable.sort
const aAttr = getObjectAttribute(a, sortBy)
const bAttr = getObjectAttribute(b, sortBy)
const isAsc = this.MdTable.sortOrder === 'asc'
let isNumber = typeof aAttr === 'number'
if (this.MdTable.sortOrder === 'desc') {
return aAttr.localeCompare(bAttr)
if (isNumber) {
return isAsc ? (bAttr - aAttr) : (aAttr - bAttr)
}
return bAttr.localeCompare(aAttr)
if (isAsc) {
return bAttr.localeCompare(aAttr)
}
return aAttr.localeCompare(bAttr)
})
}
}

0 comments on commit 18bb96c

Please sign in to comment.
You can’t perform that action at this time.