Module:Sortkey
- Afrikaans
- Аԥсшәа
- العربية
- Արեւմտահայերէն
- অসমীয়া
- Asturianu
- Авар
- Azərbaycanca
- Basa Bali
- বাংলা
- Banjar
- 閩南語 / Bân-lâm-gí
- Беларуская (тарашкевіца)
- भोजपुरी
- Bikol Central
- Bosanski
- Буряад
- Català
- Cebuano
- Chi-Chewa
- Dagbanli
- الدارجة
- Eesti
- Euskara
- فارسی
- Gaeilge
- Galego
- ગુજરાતી
- 客家語 / Hak-kâ-ngî
- 한국어
- Hausa
- Հայերեն
- Ilokano
- Bahasa Indonesia
- Íslenska
- ಕನ್ನಡ
- Ladin
- Lëtzebuergesch
- Magyar
- Madhurâ
- मैथिली
- മലയാളം
- Māori
- مازِرونی
- Bahasa Melayu
- 閩東語 / Mìng-dĕ̤ng-ngṳ̄
- Монгол
- नेपाली
- 日本語
- Oʻzbekcha / ўзбекча
- ਪੰਜਾਬੀ
- Pangasinan
- پښتو
- Português
- Română
- Русский
- Gagana Samoa
- Scots
- සිංහල
- Simple English
- سنڌي
- Slovenščina
- کوردی
- Српски / srpski
- Suomi
- Tagalog
- தமிழ்
- Taqbaylit
- တႆး
- ไทย
- Türkçe
- Українська
- اردو
- Tiếng Việt
- 吴语
- 粵語
- 中文
- Руски
Appearance
From Wikipedia, the free encyclopedia
This module is rated as ready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned on help pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed through sandbox testing rather than repeated trial-and-error editing.
Page template-protected This module is currently protected from editing.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
This module depends on the following other modules:
This module sanitizes and escapes sortkeys so that they can be used inside the data-sort-value attribute of HTML tags in combination with table sorting. Use it when you cannot be certain that the provided sortkey input is a correct sortkey.
Usage
{{#invoke:Sortkey|escape|sortkey to sanitize}}
The above documentation is transcluded from Module:Sortkey/doc. (edit | history)
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.
localgetArgs=require('Module:Arguments').getArgs localp={} functionp._encode(sortkey) -- Protect against sortkey nesting. -- Example: {{sort|{{dts|2013|07|07}}|{{dts|1990|12|01}}}} ifstring.find(sortkey,"sortkey")orstring.find(sortkey,"data-sort-value")then return""; end returnmw.text.encode(sortkey) end functionp.encode(frame) localargs=getArgs(frame); returnp._encode(args[1]or"") end localfunctionvalid_number(num) -- Return true if num is a valid number. -- In Scribunto (different from some standard Lua), when expressed as a string, -- overflow or other problems are indicated with text like "inf" or "nan" -- which are regarded as invalid here (each contains "n"). iftype(num)=='number'andtostring(num):find('n',1,true)==nilthen returntrue end end functionp._sortKeyForNumber(value) localsortkey ifnotvalid_number(value)then ifvalue<0then sortkey='1000000000000000000' else sortkey='9000000000000000000' end elseifvalue==0then sortkey='5000000000000000000' else localmag=math.floor(math.log10(math.abs(value))+1e-14) localprefix ifvalue>0then prefix=7000+mag else prefix=2999-mag value=value+10^(mag+1) end sortkey=string.format('%d',prefix)..string.format('%015.0f',math.floor(value*10^(math.min(28,14-mag)))) end returnsortkey; end functionp.sortKeyForNumber(frame) localargs=getArgs(frame); returnp._sortKeyForNumber(args[1]or"") end returnp