Add sanity check to sort function

This commit is contained in:
sapier 2013-08-25 00:43:20 +02:00 committed by Nils Dagsson Moskopp
parent 019f1b3fd6
commit af89f4a900
Signed by: erle
GPG Key ID: A3BC671C35191080
1 changed files with 6 additions and 0 deletions

View File

@ -240,6 +240,12 @@ end
function sort_worlds_alphabetic(this)
table.sort(this.m_processed_list, function(a, b)
--fixes issue #857 (crash due to sorting nil in worldlist)
if a == nil or b == nil then
if a == nil and b ~= nil then return false end
if b == nil and a ~= nil then return true end
return false
end
if a.name:lower() == b.name:lower() then
return a.name < b.name
end