Improve alphabetical sorting
This commit is contained in:
parent
222e04d2c4
commit
5a14116b69
|
@ -344,7 +344,7 @@ end
|
||||||
i3.add_sorting_method("alphabetical", {
|
i3.add_sorting_method("alphabetical", {
|
||||||
description = S"Sort items by name (A-Z)",
|
description = S"Sort items by name (A-Z)",
|
||||||
func = function(list, data)
|
func = function(list, data)
|
||||||
sorter(list, data.reverse_sorting, 1)
|
sorter(list, data, 1)
|
||||||
return list
|
return list
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@ -352,7 +352,7 @@ i3.add_sorting_method("alphabetical", {
|
||||||
i3.add_sorting_method("numerical", {
|
i3.add_sorting_method("numerical", {
|
||||||
description = S"Sort items by number of items per stack",
|
description = S"Sort items by number of items per stack",
|
||||||
func = function(list, data)
|
func = function(list, data)
|
||||||
sorter(list, data.reverse_sorting, 2)
|
sorter(list, data, 2)
|
||||||
return list
|
return list
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
|
@ -482,15 +482,16 @@ local function get_sorting_idx(name)
|
||||||
return idx
|
return idx
|
||||||
end
|
end
|
||||||
|
|
||||||
local function sorter(inv, reverse, mode)
|
local function sorter(inv, data, mode)
|
||||||
sort(inv, function(a, b)
|
sort(inv, function(a, b)
|
||||||
if mode == 1 then
|
if mode == 1 then
|
||||||
a, b = a:get_name(), b:get_name()
|
a = translate(data.lang_code, a:get_short_description())
|
||||||
|
b = translate(data.lang_code, b:get_short_description())
|
||||||
else
|
else
|
||||||
a, b = a:get_count(), b:get_count()
|
a, b = a:get_count(), b:get_count()
|
||||||
end
|
end
|
||||||
|
|
||||||
if reverse then
|
if data.reverse_sorting then
|
||||||
return a > b
|
return a > b
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Ŝarĝante…
Reference in New Issue