From d6cecb387c867f14a3a9de793e158c874a974253 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 13 Aug 2016 13:30:38 +0200 Subject: Allow function-based sorting --- init.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 6c12494..d7f0860 100644 --- a/init.lua +++ b/init.lua @@ -286,13 +286,16 @@ function doc.get_sorted_entry_names(cid) end local comp if cat.def.sorting ~= "nosort" then + -- Sorting by user function + if cat.def.sorting == "function" then + comp = cat.def.sorting_data -- Alphabetic sorting - if cat.def.sorting == "abc" or cat.def.sorting == nil then + elseif cat.def.sorting == "abc" or cat.def.sorting == nil then comp = function(e1, e2) if reverse_sort_table[e1.name] < reverse_sort_table[e2.name] then return true else return false end end - table.sort(entry_table, comp) end + table.sort(entry_table, comp) end return entry_table -- cgit v1.2.3