csv: sort by guild name

Zig Zichterman [03-14-16 - 03:10]
csv: sort by guild name

For more consistent diffing
Filename
GuildGoldDeposits_to_csv.lua
diff --git a/GuildGoldDeposits_to_csv.lua b/GuildGoldDeposits_to_csv.lua
index d409ad0..5990b34 100644
--- a/GuildGoldDeposits_to_csv.lua
+++ b/GuildGoldDeposits_to_csv.lua
@@ -18,8 +18,8 @@ end

 -- Parse the ["history'] table
 function TableHistory(history)
-    for k,v in pairs(history) do
-        guild_name = k
+    for _, guild_name in pairs(sorted_keys(history)) do
+        v = history[guild_name]
         for _,line in pairs(v) do
             time_secs, amount, user = split(line)
             WriteLine(guild_name, time_secs, amount, user)
@@ -27,6 +27,16 @@ function TableHistory(history)
     end
 end

+-- Return table keys, sorted, as an array
+function sorted_keys(tabl)
+    keys = {}
+    for k in pairs(tabl) do
+        table.insert(keys, k)
+    end
+    table.sort(keys)
+    return keys
+end
+
 function enquote(s)
     return '"' .. s .. '"'
 end