Wikipedia:Lua/Modul/Sort/en

Vorlagenprogrammierung Diskussionen Lua Test Unterseiten
Modul Deutsch English Modul: Dokumentation

Sort – module with auxilary functions to create sortable keys.

Functions for templates

Return value is always the sort key.

Tlatin

Alphanumeric terms in latin based scripts are reduced to basic characters of ASCII set.

Optional parameters
v
Variant
Default: ISO (simplify all diacritic characters; ligatures of two letters)

Casing (upcased/downcased) will remain; that can be eliminated easily from result.

textOrder

The value is 1 if the first string is lexical less than second string else empty.

Mandatory parameters, leading whitespace is significant
1
first string
2
second string

failsafe

Version management

The Failsafe interface is heading for version management of globally distributed Lua modules. It enables modules equipped with this interface to

  • ensure, that a library module required by a template or another module available as local copy does support certain functionality, or complain if not.
  • administrate global updating and linking of module codes via Wikidata.

The Failsafe interface is present both at template level and for direct Lua access.

The functions in detail are (not all supported yet completely by every library):

Parameter
Value Result current
nothing
false
local version ID »2024-06-14«
Minimal version version ID required at least
date in ISO format

It will be compared whether the current local implementation matches this version or later.

  • empty, if minimal version not achieved
  • 2001-01-01 → »2024-06-14«
  • 2099-01-01 → »«
wikidata version ID of global upstream
  • version ID at Wikidata
  • local, if not found there
»2024-06-14«
item ID of the Wikidata item
  • empty if not defined
Q24205172
~ Corresponding version ID locally and registered at Wikidata
  • empty, if up to date
  • version ID at Wikidata, if not equal
»«
@ Is the current (module) page linked correctly with Wikidata item?
  • empty, if linked to the item which is supposed
  • Iitem ID, if not
The return value is in template programming empty or under Lua false, otherwis a non-empty string as described.

Examples (test page)

A test page illustrates results on input formats.

Date and time

That is implemented by the module DateTime.

Functions for Lua modules (API)

All functions described above can be used by other modules:

local lucky, Sort = pcall( require, "Module:Sort" )
if type( Sort ) == "table" then
    Sort = Sort()
else
    -- In the event of errors, Sort is an error message.
    return "<span class='error'>" .. Sort .. "</span>"
end
Sort.lex( adjust, apply, adapt )
Similar to Tlatin.
adjust
term (string)
mandatory
apply
base script (string)
  • "latin"
  • "cyrillic"
  • "greek"
  • "uni"
currently latin available only
adapt
variant (string, optional)
  • "DIN5007m2"
Sort.failsafe( atleast )
Versioning interface similar to failsafe
atleast
optional
nil or minimum version or wikidata or ~ for synchronisation
returns: Version ID as string or false

Until 2023 Sort = Sort.Sort() has been recommended for initialization.

Installation on other WMF projects

Follow the steps:

  1. Copy main module Module:Sort into your project.
    • If possible keep the name Sort.
    • If another name is required due to conflict or naming convention or non-latin script then choose a different one.
  2. Register this module at d:Q24205172.
  3. Copy desired sub modules, and keep the chosen root name.
  4. Ready.
  5. Consider translation of doc page.
  6. Consider Module:Sort/local adaption to local wiki.

Adaption to local wiki

Module:Sort/local, if present, permits local configuration.

simpleDatePattern
pattern for #time: – formatting one particular day
Default: j M Y

Usage

General library; no limitations.

Dependencies

No other than sub modules.

Sub modules

Envisioned

Internationalisation

Not necessary.