annotate sort.lua @ 51:6f1bb8fcf64d v18

AskMrRobot.toc - Added line for new SettingsTab file AskMrRobotUi.lua - Added code for new Settings menu amr-constants.lua - Added instance IDs for all WoD 6.0 5-mans and Raids. - Removed legacy SoO IDs. config.lua - Removed "Interface/Addons" options area, migrated all settings to main addon window. localization/localization.en.lua - Added new strings for new Settings tab and new Raid auto-logging ui/CombatLogTab.lua - Removed legacy SoO code - Added auto-logging settings for Highmaul and Blackrock Foundry. ui/SettingsTab.lua - new main window tab for Minimap and Auction House settings options
author TuhMuffinMan <TuhMuffinMan>
date Fri, 28 Nov 2014 13:09:52 -0600
parents e77e01abce98
children
rev   line source
adam@0 1 local _, AskMrRobot = ...
adam@0 2
adam@0 3 function AskMrRobot.spairs(t, order)
adam@0 4 -- collect the keys
adam@0 5 local keys = {}
adam@0 6 for k in pairs(t) do keys[#keys+1] = k end
adam@0 7
adam@0 8 -- if order function given, sort by it by passing the table and keys a, b,
adam@0 9 -- otherwise just sort the keys
adam@0 10 if order then
adam@0 11 table.sort(keys, function(a,b) return order(t, a, b) end)
adam@0 12 else
adam@0 13 table.sort(keys)
adam@0 14 end
adam@0 15
adam@0 16 -- return the iterator function
adam@0 17 local i = 0
adam@0 18 return function()
adam@0 19 i = i + 1
adam@0 20 if keys[i] then
adam@0 21 return keys[i], t[keys[i]]
adam@0 22 end
adam@0 23 end
adam@0 24 end