diff --git a/fetcher/fetcher.go b/fetcher/fetcher.go index 52b450a63939d7ace3cb2c3fa86c785315674276..01e09503e5db6e6f50316a37b47a474fbae25a00 100644 --- a/fetcher/fetcher.go +++ b/fetcher/fetcher.go @@ -17,6 +17,7 @@ import ( "net/textproto" "os" "slices" + "sort" "strings" "sync" "time" @@ -502,13 +503,9 @@ func FetchMailboxEmails(account *config.Account, mailbox string, limit, offset u } // Sort batch Newest -> Oldest by UID desc - for i := 0; i < len(batchEmails); i++ { - for j := i + 1; j < len(batchEmails); j++ { - if batchEmails[j].UID > batchEmails[i].UID { - batchEmails[i], batchEmails[j] = batchEmails[j], batchEmails[i] - } - } - } + sort.Slice(batchEmails, func(i, j int) bool { + return batchEmails[i].UID > batchEmails[j].UID + }) allEmails = append(allEmails, batchEmails...) cursor = from - 1