@@ -94,17 +94,19 @@ export default {
94
94
return this . computedFields . some ( f => f . sortable )
95
95
} ,
96
96
sortedItems ( ) {
97
- // Sorts the filtered items and returns a new array of the sorted items
98
- const items = ( this . filteredItems || [ ] ) . slice ( )
97
+ // Sorts the filtered items and returns a new array of
98
+ // the sorted items, or the original array if not sorted
99
+ const items = this . filteredItems || this . localItems || [ ]
99
100
const sortBy = this . localSortBy
100
101
const sortDesc = this . localSortDesc
101
102
const sortCompare = this . sortCompare
102
103
const localSorting = this . localSorting
103
104
const sortOptions = { ...this . sortCompareOptions , usage : 'sort' }
104
105
const sortLocale = this . sortCompareLocale || undefined
105
106
const nullLast = this . sortNullLast
107
+ const fieldsObj = this . computedFieldsObj
106
108
if ( sortBy && localSorting ) {
107
- const field = this . computedFieldsObj [ sortBy ] || { }
109
+ const field = fieldsObj [ sortBy ] || { }
108
110
const sortByFormatted = field . sortByFormatted
109
111
const formatter = isFunction ( sortByFormatted )
110
112
? sortByFormatted
@@ -136,6 +138,7 @@ export default {
136
138
return ( result || 0 ) * ( sortDesc ? - 1 : 1 )
137
139
} )
138
140
}
141
+ // Else, return the original array
139
142
return items
140
143
}
141
144
} ,
0 commit comments