From 132a0e46f4bb3a01e23f180653fc676db66bbc9f Mon Sep 17 00:00:00 2001 From: fdai7172 Date: Wed, 8 Feb 2023 19:19:04 +0100 Subject: [PATCH] Die Sortierung-Funktion der Spieler wird eingebaut --- src/Paper-Bin.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Paper-Bin.c b/src/Paper-Bin.c index f0b2207..7f2942d 100644 --- a/src/Paper-Bin.c +++ b/src/Paper-Bin.c @@ -165,7 +165,7 @@ void sortScoreboard() { char* playertmp = strtok(line, " "); strcpy(playerlist[j].Name, playertmp); - + playertmp = strtok(NULL, " "); int playerPoints = atoi(playertmp); @@ -173,6 +173,18 @@ void sortScoreboard() numberOfLines = j; sleep(100); + } + struct Player temp; + for (int i = 0; i <= numberOfLines; i++) + { + if (playerlist[i].Points < playerlist[i + 1].Points) + { + temp = playerlist[i]; + playerlist[i] = playerlist[i + 1]; + playerlist[i + 1] = temp; + } + } + } fclose(fp); }