From 92762144334af5d4b5489863871fd73032c0a3f6 Mon Sep 17 00:00:00 2001 From: Grishka Date: Tue, 19 Apr 2022 15:51:23 +0300 Subject: [PATCH] Improve instance sorting --- .../fragments/onboarding/InstanceCatalogFragment.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceCatalogFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceCatalogFragment.java index d3a8d5af3..3728d6a27 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceCatalogFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceCatalogFragment.java @@ -80,6 +80,8 @@ public class InstanceCatalogFragment extends BaseRecyclerFragment result){ Map> byLang=result.stream().collect(Collectors.groupingBy(ci->ci.language)); + for(List group:byLang.values()){ + Collections.sort(group, (a, b)->{ + double aa=Math.abs(DUNBAR-Math.log(a.lastWeekUsers)); + double bb=Math.abs(DUNBAR-Math.log(b.lastWeekUsers)); + return Double.compare(aa, bb); + }); + } // get the list of user-configured system languages List userLangs; if(Build.VERSION.SDK_INT<24){