diff --git a/main.go b/main.go index 5d99744..150f2c4 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "io" "os" "os/exec" + "sort" "strconv" ) @@ -49,6 +50,21 @@ func showQueue() { fmt.Printf("Could not fetch queue entries: %s\n", err.Error()) 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" { pagerReader, pagerWriter := io.Pipe() pagerDone := make(chan bool)