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/9134227 below:

fix error to sort by attribute of child object (#1309) · vuematerial/vue-material@9134227 · GitHub

File tree Expand file treeCollapse file tree 1 file changed

+14

-2

lines changed

Filter options

Expand file treeCollapse file tree 1 file changed

+14

-2

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

@@ -60,6 +60,16 @@

60 60

import MdTableRowGhost from './MdTableRowGhost'

61 61

import MdTableCellSelection from './MdTableCellSelection'

62 62 63 +

const getObjectAttribute = (object, key) => {

64 +

let value = object

65 + 66 +

for (const attribute of key.split('.')) {

67 +

value = value[attribute]

68 +

}

69 + 70 +

return value

71 +

}

72 + 63 73

export default {

64 74

name: 'MdTable',

65 75

components: {

@@ -93,12 +103,14 @@

93 103

default (value) {

94 104

return value.sort((a, b) => {

95 105

const sortBy = this.MdTable.sort

106 +

const aAttr = getObjectAttribute(a, sortBy)

107 +

const bAttr = getObjectAttribute(b, sortBy)

96 108 97 109

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

98 -

return a[sortBy].localeCompare(b[sortBy])

110 +

return aAttr.localeCompare(bAttr)

99 111

}

100 112 101 -

return b[sortBy].localeCompare(a[sortBy])

113 +

return bAttr.localeCompare(aAttr)

102 114

})

103 115

}

104 116

}

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