Experimental feature: Sorting the queue entries
This commit is contained in:
parent
3d893015a3
commit
dd47907270
16
main.go
16
main.go
|
@ -6,6 +6,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -49,6 +50,21 @@ func showQueue() {
|
||||||
fmt.Printf("Could not fetch queue entries: %s\n", err.Error())
|
fmt.Printf("Could not fetch queue entries: %s\n", err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
// Experiment: Sort queue by Date
|
||||||
|
sort.Slice(queue.Entries, func(a int, b int) bool {
|
||||||
|
//var sortBy []string = []string{"Status", "Sender", "Date"}
|
||||||
|
//for _, sortAttribute := range sortBy {
|
||||||
|
//if sort attributes are equal continue
|
||||||
|
//else return a < b
|
||||||
|
|
||||||
|
//}
|
||||||
|
if queue.Entries[a].Date.Equal(queue.Entries[b].Date) {
|
||||||
|
return queue.Entries[a].Sender > queue.Entries[b].Sender
|
||||||
|
} else {
|
||||||
|
return queue.Entries[a].Date.Before(queue.Entries[b].Date)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
if settings["usePager"] == "true" {
|
if settings["usePager"] == "true" {
|
||||||
pagerReader, pagerWriter := io.Pipe()
|
pagerReader, pagerWriter := io.Pipe()
|
||||||
pagerDone := make(chan bool)
|
pagerDone := make(chan bool)
|
||||||
|
|
Loading…
Reference in New Issue