From f4d94f43cb43c19000649665474ba270084e0b81 Mon Sep 17 00:00:00 2001 From: pschifferer Date: Wed, 21 Oct 2009 02:56:12 +0000 Subject: [PATCH] Added a table-index sorting utility function. Made the shopping list sort items under each toon alphabetically. --- CauldronShoppingListUI.lua | 4 +++- CauldronUtil.lua | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CauldronShoppingListUI.lua b/CauldronShoppingListUI.lua index 97eb169..90ebead 100644 --- a/CauldronShoppingListUI.lua +++ b/CauldronShoppingListUI.lua @@ -109,7 +109,9 @@ function Cauldron:UpdateShoppingList() frameAbove = shoppingListRequestor; -- add items for the requestor - for item, amount in pairs(items) do + for item in pairs(Cauldron:SortTableIndices(items)) do +-- for item, amount in pairs(items) do + local amount = items[item]; local shoppingListItem = _G["CauldronShoppingListItem"..itemIndex]; diff --git a/CauldronUtil.lua b/CauldronUtil.lua index e43942f..656bfa9 100644 --- a/CauldronUtil.lua +++ b/CauldronUtil.lua @@ -230,3 +230,21 @@ function Cauldron:GetMerchantItems() return items; end + +function Cauldron:SortTableIndices(t) + + if not t then + return {}; + end + + local a = {}; + + for n in pairs(t) do + a[#a + 1] = n; + end + + table.sort(a); + + return a; +end + -- 1.7.9.5