Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rankings: make sorting stable #235

Merged
merged 1 commit into from
Nov 16, 2024
Merged

Conversation

NeKzor
Copy link
Contributor

@NeKzor NeKzor commented Nov 16, 2024

Tried to optimize a few things but then noticed that the sorting is unstable which makes it hard to detect if the result is the same as before. Sorting by Steam ID on equal scores should make it stable since that field is always unique.

Example diff for sp.json where sp_score score is the same but higher Steam ID gets sorted to the back:

-  {
-    "user_name": "MrCatMcFly",
-    "avatar_link": "https://avatars.steamstatic.com/6f89591012f8f0f34cef1ecdb1c10793b0ea4bd1_full.jpg",
-    "steam_id": "76561198168920589",
-    "sp_score": 87,
-    "mp_score": 66,
-    "overall_score": 153,
-    "sp_rank": 15,
-    "mp_rank": 109,
-    "overall_rank": 28
-  },
   {
     "user_name": "BiSaXa",
     "avatar_link": "https://avatars.steamstatic.com/90864fe6d618dfeb65e0a336ae20dd949e916242_full.jpg",
@@ -175,6 +164,17 @@
     "mp_rank": 6,
     "overall_rank": 8
   },
+  {
+    "user_name": "MrCatMcFly",
+    "avatar_link": "https://avatars.steamstatic.com/6f89591012f8f0f34cef1ecdb1c10793b0ea4bd1_full.jpg",
+    "steam_id": "76561198168920589",
+    "sp_score": 87,
+    "mp_score": 66,
+    "overall_score": 153,
+    "sp_rank": 15,
+    "mp_rank": 109,
+    "overall_rank": 28
+  },

@pektezol pektezol merged commit 3d8afc2 into pektezol:main Nov 16, 2024
@NeKzor NeKzor deleted the rankings/stable-sort branch November 22, 2024 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants