<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FSwpb%2Fsurname-sort</id>
	<title>Module:Sandbox/Swpb/surname-sort - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FSwpb%2Fsurname-sort"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Swpb/surname-sort&amp;action=history"/>
	<updated>2026-07-29T00:21:58Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Sandbox/Swpb/surname-sort&amp;diff=146250&amp;oldid=prev</id>
		<title>imported&gt;Swpb: Swpb moved page Module:Sandbox/Swpb to Module:Sandbox/Swpb/surname-sort without leaving a redirect</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Swpb/surname-sort&amp;diff=146250&amp;oldid=prev"/>
		<updated>2019-01-16T17:40:45Z</updated>

		<summary type="html">&lt;p&gt;Swpb moved page &lt;a href=&quot;/index.php?title=Module:Sandbox/Swpb&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Module:Sandbox/Swpb (page does not exist)&quot;&gt;Module:Sandbox/Swpb&lt;/a&gt; to &lt;a href=&quot;/research/Module:Sandbox/Swpb/surname-sort&quot; title=&quot;Module:Sandbox/Swpb/surname-sort&quot;&gt;Module:Sandbox/Swpb/surname-sort&lt;/a&gt; without leaving a redirect&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.surname(frame)&lt;br /&gt;
	local fullname = frame.args[1]&lt;br /&gt;
	&lt;br /&gt;
	--Pull off any generational suffix&lt;br /&gt;
	suffix1_index = mw.ustring.find(fullname, &amp;#039;,? [JS]n?r%.?$&amp;#039;)&lt;br /&gt;
	suffix2_index = mw.ustring.find(fullname, &amp;#039; [IVX]+$&amp;#039;)&lt;br /&gt;
	if type(suffix1_index) ~= &amp;#039;nil&amp;#039; then&lt;br /&gt;
		suffix = mw.ustring.sub(fullname, suffix1_index)&lt;br /&gt;
		nosuffix = mw.ustring.sub(fullname, 1, suffix1_index-1)&lt;br /&gt;
	elseif type(suffix2_index) ~= &amp;#039;nil&amp;#039; then&lt;br /&gt;
		suffix = mw.ustring.sub(fullname, suffix2_index)&lt;br /&gt;
		nosuffix = mw.ustring.sub(fullname, 1, suffix2_index-1)&lt;br /&gt;
	else&lt;br /&gt;
		suffix = &amp;#039;&amp;#039;&lt;br /&gt;
		nosuffix = fullname&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
	--Pull off last word&lt;br /&gt;
--	lastword_index = mw.ustring.find(nosuffix, &amp;#039;[ ^]%S+$&amp;#039;)&lt;br /&gt;
	if type(mw.ustring.find(nosuffix, &amp;#039; %S+$&amp;#039;)) == &amp;#039;nil&amp;#039; then&lt;br /&gt;
		lastword_index = mw.ustring.find(nosuffix, &amp;#039;^%S+$&amp;#039;)&lt;br /&gt;
	else&lt;br /&gt;
		lastword_index = mw.ustring.find(nosuffix, &amp;#039; %S+$&amp;#039;)			&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	lastword = mw.ustring.sub(nosuffix, lastword_index)&lt;br /&gt;
	nolastword = mw.ustring.sub(nosuffix, 1, lastword_index-1)&lt;br /&gt;
&lt;br /&gt;
	--Pull off second to last word&lt;br /&gt;
--	secondtolastword_index = mw.ustring.find(nolastword, &amp;#039;[ ^]%S+$&amp;#039;)&lt;br /&gt;
	secondtolastword_index = mw.ustring.find(nolastword, &amp;#039; %S+$&amp;#039;) or mw.ustring.find(nolastword, &amp;#039;^%S+$&amp;#039;)&lt;br /&gt;
	secondtolastword = mw.ustring.sub(nolastword, secondtolastword_index)&lt;br /&gt;
	nosecondtolastword = mw.ustring.sub(nolastword, 1, secondtolastword_index-1)&lt;br /&gt;
	secondtolastword_lower = mw.ustring.lower(secondtolastword)&lt;br /&gt;
&lt;br /&gt;
	prefixes = {&amp;#039;a&amp;#039;, &amp;#039;ab&amp;#039;, &amp;#039;af&amp;#039;, &amp;#039;av&amp;#039;, &amp;#039;ap&amp;#039;, &amp;#039;abu&amp;#039;, &amp;#039;al&amp;#039;, &amp;#039;ālam&amp;#039;, &amp;#039;alam&amp;#039;, &amp;#039;bar&amp;#039;, &amp;#039;bath&amp;#039;, &amp;#039;bat&amp;#039;, &amp;#039;bean&amp;#039;, &amp;#039;ben&amp;#039;, &amp;#039;bet&amp;#039;, &amp;#039;bin&amp;#039;, &amp;#039;bint&amp;#039;, &amp;#039;da&amp;#039;, &amp;#039;das&amp;#039;, &amp;#039;de&amp;#039;, &amp;#039;degli&amp;#039;, &amp;#039;del&amp;#039;, &amp;#039;dele&amp;#039;, &amp;#039;della&amp;#039;} ..&lt;br /&gt;
		{ &amp;#039;der&amp;#039;, &amp;#039;di&amp;#039;, &amp;#039;dos&amp;#039;, &amp;#039;du&amp;#039;, &amp;#039;e&amp;#039;, &amp;#039;el&amp;#039;, &amp;#039;fetch&amp;#039;, &amp;#039;vetch&amp;#039;, &amp;#039;fitz&amp;#039;, &amp;#039;i&amp;#039;, &amp;#039;ibn&amp;#039;, &amp;#039;kil&amp;#039;, &amp;#039;gil&amp;#039;, &amp;#039;la&amp;#039;, &amp;#039;le&amp;#039;, &amp;#039;lu&amp;#039;, &amp;#039;m\&amp;#039;&amp;#039;, &amp;#039;mac&amp;#039;, &amp;#039;mc&amp;#039;, &amp;#039;mck&amp;#039;, &amp;#039;mhic&amp;#039;, &amp;#039;mic&amp;#039;, &amp;#039;mag&amp;#039;, &amp;#039;mala&amp;#039;, &amp;#039;maol&amp;#039;, &amp;#039;mug&amp;#039;} ..&lt;br /&gt;
		{&amp;#039;na&amp;#039;, &amp;#039;neder&amp;#039;, &amp;#039;ní&amp;#039;, &amp;#039;ni&amp;#039;, &amp;#039;nic&amp;#039;, &amp;#039;nig&amp;#039;, &amp;#039;nin&amp;#039;, &amp;#039;nord&amp;#039;, &amp;#039;norr&amp;#039;, &amp;#039;ny&amp;#039;, &amp;#039;ó&amp;#039;, &amp;#039;o&amp;#039;, &amp;#039;öfver&amp;#039;, &amp;#039;ofver&amp;#039;, &amp;#039;ost&amp;#039;, &amp;#039;öst&amp;#039;, &amp;#039;öster&amp;#039;, &amp;#039;øst&amp;#039;, &amp;#039;över&amp;#039;, &amp;#039;over&amp;#039;, &amp;#039;öz&amp;#039;, &amp;#039;pour&amp;#039;, &amp;#039;saint&amp;#039;, &amp;#039;san&amp;#039;} ..&lt;br /&gt;
		{&amp;#039;ste&amp;#039;, &amp;#039;stor&amp;#039;, &amp;#039;söder&amp;#039;, &amp;#039;soder&amp;#039;, &amp;#039;sønder&amp;#039;, &amp;#039;sonder&amp;#039;, &amp;#039;ter&amp;#039;, &amp;#039;tre&amp;#039;, &amp;#039;ua&amp;#039;, &amp;#039;uí&amp;#039;, &amp;#039;ui\&amp;#039;&amp;#039;, &amp;#039;ui&amp;#039;, &amp;#039;van&amp;#039;, &amp;#039;väst&amp;#039;, &amp;#039;vast&amp;#039;, &amp;#039;väster&amp;#039;, &amp;#039;vaster&amp;#039;, &amp;#039;vest&amp;#039;, &amp;#039;von&amp;#039;, &amp;#039;woj&amp;#039;, &amp;#039;zu&amp;#039;}&lt;br /&gt;
	local surname, givenname&lt;br /&gt;
	for prefix in prefixes do&lt;br /&gt;
		if secondtolastword_lower == prefix then&lt;br /&gt;
			surname = secondtolastword .. &amp;#039; &amp;#039; .. lastword&lt;br /&gt;
			givenname = nosecondtolastword&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if secondtolastword_lower == &amp;#039;der&amp;#039; or secondtolastword_lower == &amp;#039;y&amp;#039; then&lt;br /&gt;
--		thirdtolastword_index = mw.ustring.find(nosecondtolastword, &amp;#039;[ ^]%S+$&amp;#039;)&lt;br /&gt;
		thirdtolastword_index = mw.ustring.find(nosecondtolastword, &amp;#039; %S+$&amp;#039;) or mw.ustring.find(nosecondtolastword, &amp;#039;^%S+$&amp;#039;)&lt;br /&gt;
		thirdtolastwod = mw.ustring.sub(nosecondtolastword, thirdtolastword_index)&lt;br /&gt;
		nothirdtolastword = mw.ustring.sub(nosecondtolastword, 1, thirdtolastword_index-1)&lt;br /&gt;
		thirdtolastword_lower = mw.ustring.lower(thirdtolastword)&lt;br /&gt;
		if (secondtolastword_lower == &amp;#039;y&amp;#039;) or (thirdtolastword_lower == &amp;#039;van&amp;#039; and secondtolastword_lower == &amp;#039;der&amp;#039;) then&lt;br /&gt;
			surname = thirdtolastword .. &amp;#039; &amp;#039; .. secondtolastword .. &amp;#039; &amp;#039; .. lastword&lt;br /&gt;
			givenname = nothirdtolastword&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		surname = lastword&lt;br /&gt;
		givenname = nolastword&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	sortname = surname .. &amp;#039;, &amp;#039; .. givenname .. &amp;#039; &amp;#039; .. suffix&lt;br /&gt;
	return sortname&lt;br /&gt;
--]]&lt;br /&gt;
	return nosuffix&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Swpb</name></author>
	</entry>
</feed>