Module:ClassMemoryCategoryList

local class_link = require('Module:Class link')._class_link

local p = {}

--% This function generates a list of classes by their memory category. --: (string) the list of classes function p.list_classes_by_memory_category local memory_categories = {} local uncategorized_classes = {} for _, class in pairs(require("Module:APIClasses")) do       if class.MemoryCategory then if not memory_categories[class.MemoryCategory] then memory_categories[class.MemoryCategory] = {} end table.insert(memory_categories[class.MemoryCategory], class.Name) else table.insert(uncategorized_classes, class) end end local sorted_memory_categories = {} for memory_category in pairs(memory_categories) do       table.insert(sorted_memory_categories, memory_category) end table.sort(sorted_memory_categories) local output = "" for _, memory_category in ipairs(sorted_memory_categories) do       output = output .. "== " .. memory_category .. " ==\n" table.sort(memory_categories[memory_category]) for _, class_name in ipairs(memory_categories[memory_category]) do           output = output .. "* " .. class_link{class=class_name} .. "\n" end end if #uncategorized_classes > 0 then output = output .. "== Uncategorized ==\n" table.sort(uncategorized_classes) for _, class_name in ipairs(uncategorized_classes) do           output = output .. "* " .. class_link{class=class_name} .. "\n" end end return output end

return p