2.1 Sorting Images by Filename on Category Pages
By default, when images are sorted on Category pages (on MediaWiki 1.10), they are sorted by their complete name, which means they all end up under "I". The solution is a quick template.
Step 1: Change LocalSettings.py
When image pages are categorized, they are shown in a gallery format by default, which is a table of thumbnailed images. The first thing you need to do if you want them sorted by filename is to change the $wgCategoryMagicGallery setting (which is true by default. In LocalSettings.py, you should add the following line:
$wgCategoryMagicGallery = false;
This will now display the files without thumbnails, just like every other page. The problem is that the sort order is based upon the full name, so they are all sorted under "I" since they are named things like Image:somefile.doc, and so on. The simple work-around is to specify the sort order when categorizing the file. When you categorize an image, you add code like this to the page:
[[Category:SomeCategory]]
In order to avoid sorting with the "Image" prefix, you need to specify a sort key, which can be any arbitrary word, but is often the name of the file:
[[Category:SomeCategory|somefile.doc]]
Now, if you go to the SomeCategory Category page, you'll see that somefile.doc is listed under "S".
Important: Do not leave a space after the "|" character. If you do, the file will be unsorted altogether.
Step 2: Create a template
Wiki users often want to minimize the amount of wikitext they have to use and adding the sort key adds just a little more complexity to the task that they won't like. One quick solution is to create a template that automatically adds the sort key to the category, based upon the name of the page.
To do this, you must first create a template by creating a page called Template:Category. Then edit this page and add the following code:
[[Category:{{{1}}}|{{PAGENAME}}]]
Save the page and the template has been created. When you reference a template from another page, the content from the template is embedded, or transcluded in the calling page. You call the template based on its name, so this template will be called Category and will be used like so:
{{Category|SomeCategory}}
The template name is "Category". The text that follows the "|" character are the template's parameters. This template has one parameter, "SomeCategory", and this value will be displayed in place of {{{1}}} in the template itself.
You'll also notice in the template the use of a magic word {{{PAGENAME}}}. When this magic word is used on a page, the page name for the containing document is displayed in its place. If you go to the Template:Category page, you'll see that the name of the template is displayed in that spot, so that it looks like \[\[Category:{{{1}}}. If you see this, don't worry. When the template is transcluded in another page, the name of the page doing the transcluding will be displayed.
Once this is done, you can now include pages in categories using a slightly different syntax than the original category syntax, but with the advantage of automatically specifying the sort field based upon the page name itself.