Skip to content

Commit

Permalink
fix(MdTable): improve sort function on table for numbered columns (#1353
Browse files Browse the repository at this point in the history
)

fix #1349
  • Loading branch information
VdustR authored and marcosmoura committed Dec 27, 2017
1 parent 567e9a7 commit 18bb96c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/components/MdTable/MdTable.vue
Expand Up @@ -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)
})
}
}
Expand Down

0 comments on commit 18bb96c

Please sign in to comment.