added -D to alter sort order to descending order (default: ascending)

This commit is contained in:
2022-10-15 14:24:43 +02:00
parent 752406815c
commit ebd391df63
7 changed files with 19 additions and 6 deletions

View File

@@ -76,7 +76,8 @@ var (
VERSION string
// sorting
SortByColumn int
SortByColumn int
SortDescending bool
)
// contains a whole parsed table

View File

@@ -41,6 +41,9 @@ func sortTable(data *Tabdata, col int) {
// actual sorting
sort.SliceStable(data.entries, func(i, j int) bool {
if SortDescending {
return data.entries[i][col] > data.entries[j][col]
}
return data.entries[i][col] < data.entries[j][col]
})
}