Module:RaritySort: Difference between revisions

No edit summary
No edit summary
Line 2: Line 2:


function p.getSortValue(rarity)
function p.getSortValue(rarity)
     if type(rarity) ~= "string" then
    -- Return 99 if rarity is nil or not a string
         return 99 -- Default fallback for nil or non-string
     if rarity == nil or type(rarity) ~= "string" then
         return 99
     end
     end


     local r = rarity:lower()
     local r = mw.ustring.lower(rarity)


     if r == "always" then
     if r == "always" then
Line 17: Line 18:
         return 4
         return 4
     else
     else
         return 99 -- Unknown or fallback
         return 99
     end
     end
end
end


return p
return p