Module:Auto sort
Appearance
Automatic sortkey generation functions.
The functions are designed to be called from other Lua modules.
normalTitles
[edit]Sortkeys suitable for "normal" English page titles.
English articles ('A', 'An' and 'The') are removed and tacked on at the end.
E.g. The Foo
→ Foo, The
.
--[=[
Simple functions for constructing sort keys
]=]
local p = {} --p stands for package
--[=[
This function is the usual function for titles
Be default, it strips english articles: A, An, The and puts them at the end of the string
]=]
function p.normalTitles( title )
local articles = { 'A', 'An', 'The' }
for _, article in pairs( articles ) do
-- starts with the article
if mw.ustring.find( title, article .. ' ', 1 ) == 1 then
title = mw.ustring.sub( title, mw.ustring.len( article ) + 2 ) .. ', ' .. article
break
end
end
return title
end
return p