Difference between revisions of "Template:AutoDEFAULTSORT"

From Disobiki
Jump to navigation Jump to search
Line 1: Line 1:
<includeonly>{{#ifeq: {{#pos:{{PAGENAME}}|A &#32;|}} | 0 |
+
<includeonly>{{#ifeq: {{#rmatch:{{PAGENAME}}|^(A{{!}}The)\s|1}} | 1 |
   {{DEFAULTSORT:{{#replace:{{PAGENAME}}|A &#32;|}}, A}}
+
   {{DEFAULTSORT:{{#rreplace:{{PAGENAME}}|^(A{{!}}The)\s(.*?)$|$2, $1}}}}
| }}
 
{{#ifeq: {{#pos:{{PAGENAME}}|The &#32;}} | 0 |
 
  {{DEFAULTSORT:{{#replace:{{PAGENAME}}|The &#32;|}}, The}}
 
 
| }}</includeonly><noinclude>
 
| }}</includeonly><noinclude>
 
==Usage==
 
==Usage==

Revision as of 10:30, 14 August 2010

Usage

Given "The Sinful Dwarf", return {{DEFAULTSORT:Sinful Dwarf, The}}. Handles "A Fistful of Dollars" too.
It's not perfect: if "The" or "A" (capitalized) appear elsewhere in title, it'll remove those from the DEFAULTSORT result.

 {{AutoDEFAULTSORT}}