From 631e5c37b4df48bd68f9c4e1b8ace033aca05b5a Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Sun, 25 May 2025 00:40:29 +1000 Subject: [PATCH] Improve how simple (number-indexed) Lua tables are printed also might change sort order for associative tables in some edge cases --- .../tools/Lua/Libraries/ConsoleLuaLibrary.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/ConsoleLuaLibrary.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/ConsoleLuaLibrary.cs index a3cf1e885f..4a324bfddd 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/ConsoleLuaLibrary.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/ConsoleLuaLibrary.cs @@ -69,7 +69,12 @@ namespace BizHawk.Client.EmuHawk { var entries = ((IEnumerator>) lti.GetEnumerator()).AsEnumerable() .ToArray(); - return string.Concat(entries.Select(static kvp => $"\"{kvp.Key}\": \"{kvp.Value}\"\n").Order()); + Console.WriteLine(entries[0].Key.GetType().FullName); + return string.Concat(entries.All(static kvp => kvp.Key is long) + ? entries.OrderBy(static kvp => (long) kvp.Key, Comparer.Default) + .Select(static kvp => $"{kvp.Key}: \"{kvp.Value}\"\n") + : entries.OrderBy(static kvp => kvp.Key) + .Select(static kvp => $"\"{kvp.Key}\": \"{kvp.Value}\"\n")); } if (!Tools.Has())