Fix sorting not working as expected

This commit is contained in:
Jan Philipp Timme 2019-01-01 15:17:21 +01:00
parent 23277a9159
commit eadaf8d420
1 changed files with 7 additions and 7 deletions

View File

@ -104,37 +104,37 @@ func (queue MailQ) Sort(config qEntrySortConfig) {
skip = false skip = false
switch sortBy.attribute { switch sortBy.attribute {
case "Id": case "Id":
if queue.Entries[a].Id != queue.Entries[b].Id { if queue.Entries[a].Id == queue.Entries[b].Id {
skip = true skip = true
} }
cmp = queue.Entries[a].Id < queue.Entries[b].Id cmp = queue.Entries[a].Id < queue.Entries[b].Id
case "Status": case "Status":
if queue.Entries[a].Status != queue.Entries[b].Status { if queue.Entries[a].Status == queue.Entries[b].Status {
skip = true skip = true
} }
cmp = queue.Entries[a].Status < queue.Entries[b].Status cmp = queue.Entries[a].Status < queue.Entries[b].Status
case "Date": case "Date":
if !queue.Entries[a].Date.Equal(queue.Entries[b].Date) { if queue.Entries[a].Date.Equal(queue.Entries[b].Date) {
skip = true skip = true
} }
cmp = queue.Entries[a].Date.Before(queue.Entries[b].Date) cmp = queue.Entries[a].Date.Before(queue.Entries[b].Date)
case "Size": case "Size":
if queue.Entries[a].Size != queue.Entries[b].Size { if queue.Entries[a].Size == queue.Entries[b].Size {
skip = true skip = true
} }
cmp = queue.Entries[a].Size < queue.Entries[b].Size cmp = queue.Entries[a].Size < queue.Entries[b].Size
case "Sender": case "Sender":
if queue.Entries[a].Sender != queue.Entries[b].Sender { if queue.Entries[a].Sender == queue.Entries[b].Sender {
skip = true skip = true
} }
cmp = queue.Entries[a].Sender < queue.Entries[b].Sender cmp = queue.Entries[a].Sender < queue.Entries[b].Sender
case "Recipients": case "Recipients":
if len(queue.Entries[a].Recipients) != len(queue.Entries[b].Recipients) { if len(queue.Entries[a].Recipients) == len(queue.Entries[b].Recipients) {
skip = true skip = true
} }
cmp = len(queue.Entries[a].Recipients) < len(queue.Entries[b].Recipients) cmp = len(queue.Entries[a].Recipients) < len(queue.Entries[b].Recipients)
case "Reason": case "Reason":
if queue.Entries[a].Reason != queue.Entries[b].Reason { if queue.Entries[a].Reason == queue.Entries[b].Reason {
skip = true skip = true
} }
cmp = queue.Entries[a].Reason < queue.Entries[b].Reason cmp = queue.Entries[a].Reason < queue.Entries[b].Reason