From 9e22b999f29eaad5584e672e390b4f6a3498ec09 Mon Sep 17 00:00:00 2001 From: reginald-mclean <72816837+reginald-mclean@users.noreply.github.com> Date: Tue, 5 Nov 2024 21:59:16 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20Farama-F?= =?UTF-8?q?oundation/Metaworld@cca35cff0ec62f1a18b11440de6b09e2d10a1380=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _static/versioning/versioning_menu.html | 38 ++++++++++++++++++------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/_static/versioning/versioning_menu.html b/_static/versioning/versioning_menu.html index 1daf4cef7..68109cf86 100644 --- a/_static/versioning/versioning_menu.html +++ b/_static/versioning/versioning_menu.html @@ -122,15 +122,33 @@ }); const sortVersions = (a, b) => { - // Alpha versions - if (a.includes("a")) return 1; - if (b.includes("a")) return -1; - if (a.replace("v", "") > b.replace("v", "")) - return -1 - else if (a.replace("v", "") < b.replace("v", "")) - return 1 - else - return 0 + const innerA = a.replace("v", ""); + const innerB = b.replace("v", ""); + + if (innerA.match(/[a-z]/) && !innerB.match(/[a-z]/)) return 1; + if (!innerA.match(/[a-z]/) && innerB.match(/[a-z]/)) return -1; + + const splittedInnerA = innerA.split(""); + const splittedInnerB = innerB.split(""); + + while (splittedInnerA.length && splittedInnerB.length) { + const charA = splittedInnerA.shift(); + const charB = splittedInnerB.shift(); + + if (charA === charB) continue; + else if (charA === ".") return 1; + else if (charB === ".") return -1; + else if (charA.match(/[0-9]/) && charB.match(/[0-9]/)) { + return Number(charB) - Number(charA); + } else { + if (charA < charB) return 1; + else if (charA > charB) return -1; + else return 0; + } + } + if (innerA < innerB) return 1; + else if (innerA > innerB) return -1; + else return 0; } if ((githubUser !== null && githubUser !== "") || (repo !== null && repo !== "")) { @@ -204,4 +222,4 @@ console.error("Invalid versioning configuration"); } - \ No newline at end of file +