deal with missing sort_by parameter

This commit is contained in:
Sokomine 2022-01-05 23:44:30 +01:00
parent 17a8551f25
commit f00d7bb505

View File

@ -1077,8 +1077,12 @@ yl_speak_up.get_sorted_options = function(options, sort_by)
end
table.sort(sorted_list,
function(a,b)
if(not(options[a][sort_by])) then
return false
elseif(not(options[b][sort_by])) then
return true
-- sadly not all entries are numeric
if(tonumber(options[a][sort_by]) and tonumber(options[b][sort_by])) then
elseif(tonumber(options[a][sort_by]) and tonumber(options[b][sort_by])) then
return (tonumber(options[a][sort_by]) < tonumber(options[b][sort_by]))
-- numbers have a higher priority
elseif(tonumber(options[a][sort_by])) then