Template:NameSort: Difference between revisions

From Tardis Wiki, the free Doctor Who reference
no edit summary
(adding provisions for single word names)
No edit summary
Line 1: Line 1:
<includeonly>{{DEFAULTSORT:
<includeonly>{{DEFAULTSORT:
{{#switch:{{#rpos:{{PAGENAME}}| }}
{{#switch:{{#rpos:{{PAGENAME}}|)}}
|-1={{PAGENAME}}
  |-1= <!--if there are no close parentheses, then look for spaces-->
|#default={{#sub:{{PAGENAME}}|{{#rpos:{{PAGENAME}}| }}|7}}}}
    {{#switch:{{#rpos:{{PAGENAME}}| }}
}}</includeonly><noinclude>[[Category:coding utility templates|Name]]{{documentation}}{{lock}}</noinclude>
    <!--if there are no spaces, then just go by the PAGENAME-->
    |-1 = {{PAGENAME}}
    <!--if there ARE spaces, then find the last word and use the first six digits
          of it as the sort key -->
    |#default ={{#sub:{{PAGENAME}}|{{#rpos:{{PAGENAME}}| }}|7}},{{#explode:{{#sub{{PAGENAME}}|
}} <!-- first switch close-->
  <!-- If there ARE close parentheses, use the word that immediately precedes the
      open parentheses as the sort key -->
  |#default = {{#explode:{{#sub:{{PAGENAME}}|0|{{#expr:{{#rpos:{{PAGENAME}}|(}}-1}}}}| |-1}}
 
}} <!--second switch close-->
}} <!--DEFAULTSORT close--></includeonly><noinclude>[[Category:coding utility templates|Name]]{{documentation}}{{lock}}</noinclude>
85,404

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.