summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua15
1 files changed, 11 insertions, 4 deletions
diff --git a/init.lua b/init.lua
index c0e02aa..2fc7917 100644
--- a/init.lua
+++ b/init.lua
@@ -256,7 +256,8 @@ end
function doc.get_sorted_entry_names(cid)
local sort_table = {}
local entry_table = {}
- for eid,entry in pairs(doc.data.categories[cid].entries) do
+ local cat = doc.data.categories[cid]
+ for eid,entry in pairs(cat.entries) do
local new_entry = table.copy(entry)
new_entry.eid = eid
table.insert(entry_table, new_entry)
@@ -267,10 +268,16 @@ function doc.get_sorted_entry_names(cid)
for i=1, #sort_table do
reverse_sort_table[sort_table[i]] = i
end
- local comp = function(e1, e2)
- if reverse_sort_table[e1.name] < reverse_sort_table[e2.name] then return true else return false end
+ -- Sorting algorithm
+ local comp
+ if cat.def.sorting ~= "nosort" then
+ if 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
end
- table.sort(entry_table, comp)
return entry_table
end