A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/vuematerial/vue-material/commit/18bb96c below:

improve sort function on table for numbered columns (#1… · vuematerial/vue-material@18bb96c · GitHub

File tree Expand file treeCollapse file tree 1 file changed

+9

-3

lines changed

Filter options

Expand file treeCollapse file tree 1 file changed

+9

-3

lines changed Original file line number Diff line number Diff line change

@@ -105,12 +105,18 @@

105 105

const sortBy = this.MdTable.sort

106 106

const aAttr = getObjectAttribute(a, sortBy)

107 107

const bAttr = getObjectAttribute(b, sortBy)

108 +

const isAsc = this.MdTable.sortOrder === 'asc'

109 +

let isNumber = typeof aAttr === 'number'

108 110 109 -

if (this.MdTable.sortOrder === 'desc') {

110 -

return aAttr.localeCompare(bAttr)

111 +

if (isNumber) {

112 +

return isAsc ? (bAttr - aAttr) : (aAttr - bAttr)

111 113

}

112 114 113 -

return bAttr.localeCompare(aAttr)

115 +

if (isAsc) {

116 +

return bAttr.localeCompare(aAttr)

117 +

}

118 + 119 +

return aAttr.localeCompare(bAttr)

114 120

})

115 121

}

116 122

}

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4