From 67e2dbf213d21330c91fc7cc8ac365641614909e Mon Sep 17 00:00:00 2001 From: AmorimDSJM Date: Fri, 24 Nov 2023 16:30:57 +0100 Subject: [PATCH] Sorting almost finished --- js/main.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/js/main.js b/js/main.js index cc1fb4d..9ddc4b0 100644 --- a/js/main.js +++ b/js/main.js @@ -37,7 +37,7 @@ $(document).ready(function() { -function listAgent(page, limit){ +function listAgent(page = 1, limit = 20, agents = []){ const settings = { async: true, crossDomain: true, @@ -51,13 +51,29 @@ function listAgent(page, limit){ limit: limit } }; - + + $.ajax(settings).done(function (response) { - console.log(response); - }); + const agents = response.data + console.log(response.meta) + agents.sort((a1, a2) => { + if(a1.credits < a2.credits) + return -1 + if(a1.credits > a2.credits) + return 1 + return 0 + }) + agents.reverse() + console.log(agents); + let nbTour = agents.Length; + for(i = 0; i < nbTour; i++) + { + let agents = listAgent(i, 20, false) + } + }) } $(document).ready(function() { - let leaderboard = listAgent("374", "1"); + }) \ No newline at end of file