(sort: Sort)
| 148 | sortedData = this.desserts.slice(); |
| 149 | |
| 150 | sortData(sort: Sort) { |
| 151 | const data = this.desserts.slice(); |
| 152 | |
| 153 | if (!sort.active || sort.direction === '') { |
| 154 | this.sortedData = data; |
| 155 | } else { |
| 156 | this.sortedData = data.sort((a, b) => { |
| 157 | const aValue = (a as any)[sort.active]; |
| 158 | const bValue = (b as any)[sort.active]; |
| 159 | return (aValue < bValue ? -1 : 1) * (sort.direction === 'asc' ? 1 : -1); |
| 160 | }); |
| 161 | } |
| 162 | } |
| 163 | } |
no test coverage detected