Jump to content

Module:Sort title/doc: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
No edit summary
Line 1: Line 1:
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
{{Lua|Module:Arguments|Module:String}}
{{Lua|Module:Arguments|Module:String}}

'''Module:Sort title''' is used to create [[WP:SORTKEY|sortkeys]] for pages. The module preforms the following checks:
'''Module:Sort title''' is used to create [[WP:SORTKEY|sortkeys]] for pages.

== What it does ==
The module preforms the following checks:
* If the first word of the title is an [[Article (grammar)|article]], it moves it to the end of the title. For example: <code>The Avengers</code> will have a sortkey of <code>Avengers, The</code>.
* If the first word of the title is an [[Article (grammar)|article]], it moves it to the end of the title. For example: <code>The Avengers</code> will have a sortkey of <code>Avengers, The</code>.
* If the title is disambiguated and the first word of the disambiguation is an [[Article (grammar)|article]], it moves it to the end of the disambiguation. For example: <code>Pilot (The Flash)</code> will have a sortkey of <code>Pilot (Flash, The)</code>.
* If the title is disambiguated and the first word of the disambiguation is an [[Article (grammar)|article]], it moves it to the end of the disambiguation. For example: <code>Pilot (The Flash)</code> will have a sortkey of <code>Pilot (Flash, The)</code>.
Line 8: Line 12:


== Usage ==
== Usage ==
From template:
* From a template, returns a sortkey: <code><nowiki>{{</nowiki>#invoke:{{BASEPAGENAME}}|getSortKey}}</code>
* {{Mlx|{{BASEPAGENAME}}|getSortKey}}
* From a template, returns a [[WP:DEFAULTSORT|DEFAULTSORT]] string: <code><nowiki>{{</nowiki>#invoke:{{BASEPAGENAME}}|getDefaultSort}}</code>
* {{Mlx|{{BASEPAGENAME}}|getDefaultSort}}
* From a module, returns a sortkey: <source lang="lua">local sortkeyModule = require('Module:Sort title')

From module:
<source lang="lua">local sortkeyModule = require('Module:Sort title')
local sortkey = sortkeyModule._getSortKey()
local sortkey = sortkeyModule._getSortKey()
</source >
</source >

== Function list ==
{| class="wikitable"
|-
! scope="col" | Function
! scope="col" | Explanation
|-
! scope="row" | <code>getSortKey</code>
| Returns a sortkey
|-
! scope="row" | <code>getDefaultSort</code>
| Returns a [[WP:DEFAULTSORT|DEFAULTSORT]] string
|}


<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | |
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | |

Revision as of 14:02, 10 January 2020

Module:Sort title is used to create sortkeys for pages.

What it does

The module preforms the following checks:

  • If the first word of the title is an article, it moves it to the end of the title. For example: The Avengers will have a sortkey of Avengers, The.
  • If the title is disambiguated and the first word of the disambiguation is an article, it moves it to the end of the disambiguation. For example: Pilot (The Flash) will have a sortkey of Pilot (Flash, The).
  • If the title is disambiguated and the first word of the title and the disambiguation is an article, both of the above changes will occur. For example: The End (A Series of Unfortunate Events) will have a sortkey of End, The (Series of Unfortunate Events, A).
  • If the title is a number which is separated by a commas, it removes the commas. For example: 4,722 Hours will have a sortkey of 4722 Hours.

Usage

From template:

From module:

local sortkeyModule = require('Module:Sort title')
local sortkey = sortkeyModule._getSortKey()

Function list

Function Explanation
getSortKey Returns a sortkey
getDefaultSort Returns a DEFAULTSORT string