diff options
author | Kegsay <kegan@matrix.org> | 2020-06-02 16:18:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-02 16:18:01 +0100 |
commit | e37720be441aa57aa8b30ce80b73cc151d1b2b0c (patch) | |
tree | b927ce596540ce63cc57bf12f6a41e6d6a659f76 | |
parent | 02b150fd13f64bae551d5a7fd967caf4479981b8 (diff) |
Sort public rooms again by member count (#1083)
-rw-r--r-- | publicroomsapi/directory/public_rooms.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/publicroomsapi/directory/public_rooms.go b/publicroomsapi/directory/public_rooms.go index bc40da51..df9df8ff 100644 --- a/publicroomsapi/directory/public_rooms.go +++ b/publicroomsapi/directory/public_rooms.go @@ -18,6 +18,7 @@ import ( "context" "math/rand" "net/http" + "sort" "strconv" "sync" "time" @@ -112,6 +113,11 @@ func GetPostPublicRoomsWithExternal( haveRoomIDs[r.RoomID] = true publicRooms = append(publicRooms, r) } + // sort by member count + sort.SliceStable(publicRooms, func(i, j int) bool { + return publicRooms[i].JoinedMembersCount > publicRooms[j].JoinedMembersCount + }) + response.Chunk = publicRooms return util.JSONResponse{ |