Fix vimwiki reviews lua week sorting

pull/1/head
Ensar Sarajčić 2021-03-12 16:45:29 +01:00
parent bcd840765c
commit e58ae3205a
1 changed files with 6 additions and 4 deletions

View File

@ -277,12 +277,14 @@ function M.vimwiki_review_index(vimwiki_index)
-- Sort weeks
local weeks = index[year].months[month].weeks
table.sort(weeks, function(a, b) return a > b end)
local sorted = {}
for k in pairs(weeks) do table.insert(sorted, k) end
table.sort(sorted, function(a, b) return a > b end)
-- Add weeks
local count = tablelength(weeks)
for _, week in pairs(weeks) do
table.insert(lines, '- [Week #' .. count .. ' Review](' .. week .. ')')
local count = tablelength(sorted)
for _, week in pairs(sorted) do
table.insert(lines, '- [Week #' .. count .. ' Review](' .. weeks[week] .. ')')
count = count - 1
end