LET THERE BE ORDER

This commit is contained in:
daru
2022-08-19 18:05:54 +02:00
parent 074a4a88f0
commit beed95eed9
5 changed files with 34 additions and 15 deletions

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"log"
"sort"
"strconv"
"strings"
"time"
@@ -643,6 +644,12 @@ func watchGetLogic(ctx *fasthttp.RequestCtx) ([]AnimeUser, error) {
}
animesUsers = filteredAnimes
}
sort.Slice(animesUsers, func(i, j int) bool { return animesUsers[i].Anime < animesUsers[j].Anime })
sort.SliceStable(animesUsers, func(i, j int) bool {
return AverageEpPerUser(animesUsers[i].Users) > AverageEpPerUser(animesUsers[j].Users)
})
return animesUsers, err
}