File tree 1 file changed +14
-2
lines changed
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 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
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.
0 commit comments