From c1f90626459eb5e6b5a89d1eea6003a0a71b50d6 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Sun, 21 Jul 2024 23:24:13 +0200 Subject: [PATCH] Sort loadouts dropdown based on name + number Signed-off-by: Tomas Slusny --- src/Modules/Build.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Modules/Build.lua b/src/Modules/Build.lua index 20bdd21f40..7724f2394c 100644 --- a/src/Modules/Build.lua +++ b/src/Modules/Build.lua @@ -973,6 +973,21 @@ function buildMode:SyncLoadouts(reset) end end + table.sort(filteredList, function(a, b) + local aText, aNum = a:match("^(.+) {%d+}$"), tonumber(a:match("{(%d+)}")) + local bText, bNum = b:match("^(.+) {%d+}$"), tonumber(b:match("{(%d+)}")) + if not aText then + aText, aNum = a, 0 + end + if not bText then + bText, bNum = b, 0 + end + if aText ~= bText then + return aText < bText + end + return aNum < bNum + end) + t_insert(filteredList, "-----") t_insert(filteredList, "New Loadout") t_insert(filteredList, "Sync")