Module:ModifierTables: Difference between revisions

Sort modifier tables alphabetically by default if more than one argument is passed in
(ModifierTable should now sort alphabetically when more than one modifier is requested)
(Sort modifier tables alphabetically by default if more than one argument is passed in)
Line 311: Line 311:
   if hasOtherModifiers then result = result..'!!Other Modifiers' end
   if hasOtherModifiers then result = result..'!!Other Modifiers' end


   table.sort(tableArray, function(a, b)
   --Sort by value if only one modifier was passed in
                          if modifierCount > 1 and a.val ~= b.val then
  --Otherwise sort alphabetically by name
                            return a.val > b.val
  if modifierCount == 1 then
                          elseif a.name ~= b.name then
    table.sort(tableArray, function(a, b)
                            return a.name < b.name
                            if a.val ~= b.val then
                          else
                              return a.val > b.val
                            return a.type < b.type
                            elseif a.name ~= b.name then
                           end
                              return a.name < b.name
                        end)
                            else
                              return a.type < b.type
                            end
                           end)
  else
    table.sort(tableArray, function(a, b) return a.name < b.name end)
  end
   for i, row in Shared.skpairs(tableArray) do
   for i, row in Shared.skpairs(tableArray) do
     result = result..'\r\n|-'
     result = result..'\r\n|-'