Sort articles on people by last name

From FollowTheScore
Revision as of 15:33, 15 August 2008 by Gero (talk | contribs) (New page: '''This page explains how article on people can be sorted by the last name of people although the articles' names sound like "FirstName(s) LastName".''' ---- This is a listing of all art...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page explains how article on people can be sorted by the last name of people although the articles' names sound like "FirstName(s) LastName".


This is a listing of all articles which describe members of the category "Fictional Character".

As you can see you will get a listing which is ordered by the first name as this is also the title of the respective articles.

With "replaceintitle" you can manipulate the appearance of the names but the order will still be determined by the article names and not by the changed label:

So we must create a sortable list which allows the user to click once for a LastName ordering:

{{#dpl:
 |replaceintitle=/([A-Za-z ]*)( [A-Za-z]+)$/,\2, \1
 |category=Fictional Character
 |format={{(!}}class=sortable\n!Fictional Characters\n{{!}}-,\n{{!}}[[%PAGE%{{!}}%TITLE%]],\n{{!}}-,\n{{!)}}
}}

which will produce the following:

Fictional Characters
Potter, Harry
Granger, Hermione Jean

To improve readability we can use our special characters for pipe and newline. And the whole thing will be easier to use if we put the code into a separate template which takes the category as an argument. Then the only thing we have to write is

{{list articles on people by last name|Fictional Character}}

And we will get the same result as above:


Fictional Characters
Potter, Harry
Granger, Hermione Jean