sortByStr sorts the buffer by column in string mode colIndex: column to sort by rev: true for descending, false for ascending
(colIndex int, rev bool)
| 269 | // colIndex: column to sort by |
| 270 | // rev: true for descending, false for ascending |
| 271 | func (b *Buffer) sortByStr(colIndex int, rev bool) { |
| 272 | hasHeader := I2B(b.rowFreeze) |
| 273 | |
| 274 | if rev { |
| 275 | // Descending sort |
| 276 | if hasHeader { |
| 277 | sort.SliceStable(b.cont[1:], func(i, j int) bool { |
| 278 | return b.cont[1:][i][colIndex] > b.cont[1:][j][colIndex] |
| 279 | }) |
| 280 | } else { |
| 281 | sort.SliceStable(b.cont, func(i, j int) bool { |
| 282 | return b.cont[i][colIndex] > b.cont[j][colIndex] |
| 283 | }) |
| 284 | } |
| 285 | } else { |
| 286 | // Ascending sort |
| 287 | if hasHeader { |
| 288 | sort.SliceStable(b.cont[1:], func(i, j int) bool { |
| 289 | return b.cont[1:][i][colIndex] < b.cont[1:][j][colIndex] |
| 290 | }) |
| 291 | } else { |
| 292 | sort.SliceStable(b.cont, func(i, j int) bool { |
| 293 | return b.cont[i][colIndex] < b.cont[j][colIndex] |
| 294 | }) |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | // sortByNum sorts column by number format with optimized numeric conversion |
| 300 | func (b *Buffer) sortByNum(colIndex int, rev bool) { |