Extension:SubpageSortkey

What can this extension do?
This extension changes the default sortkey from the full page name, to something involving the subpage structure of the page name. For example it can be configured to make Foo/bar/baz sort under bar/baz or baz/Foo or baz, etc.

Usage
This has a config option which contains a bunch of comma separated numbers and ranges to determine what parts of the page title will be used for the default sortkey. represents the base page name,  represents the first subpage, etc. Negative numbers count backwards;   is the last subpage-part of the title. ranges are denoted with  - aka   is the same as. The second number in the range is optional, and negative ranges are slightly weird (second number is not inclusive). This is easiest explained in examples:
 * will sort the page 0/1/2/3/4 under 1/0/2
 * will sort the page 0/1/2/3/4 under 2/0/1/2/3
 * will sort the page 0/1/2/3/4 under 4/0
 * will sort the page 0/1/2/3/4 under 1/2/3/4
 * will sort the page 0/1/2/3/4 under 1/2/3 (not under 1/2/3 /4 )
 * will sort the page 0/1/2/3/4 under 1/2/3/4

You can also customize the default sortkey per namespace with. Example: ;

can be used to control what happens if the subpage sorting comes up with an empty string (aka  on a page with no subpages) Setting it to   (default) means it will use the page's title as the sortkey. Setting to  means it will use the empty string.

Other details
can be used to control what happens if the subpage sorting comes up with an empty string (aka  on a page with no subpages) Setting it to   (default) means it will use the page's title as the sortkey. Setting to  means it will use the empty string.

The full page name (minus the namespace name) will be used as a tie-breaker in sorting. You can still use  to override this extension.

Installation
To install this extension, add the following to LocalSettings.php: And then run the maintenance script  (important!)