Jump to content
Main menu
Main menu
move to sidebar
hide
Panyanja
Tsamba lalikulu
Tsamba la anthu wonse
Current events
Kusintha kumene kwachitika posachedwa
mwachisawawa Tsamba
Chithandizo
Helpful Pages
Mafunso
Thandizo
Nkhani Zofuna Kukonza
Kalembedwe ka nkhani
Fufuzani
Fufuzani
Appearance
Perekani
Pangani akaunti
Lowani muakaunti
Zida zawekha
Perekani
Pangani akaunti
Lowani muakaunti
Pages for logged out editors
learn more
Contributions
Kulankhula
Editing
Module:Sortkey
Add languages
Module
Kukambirana
English
Read
Edit source
Onani mbiri
zida
Tools
move to sidebar
hide
Actions
Read
Edit source
Onani mbiri
General
Chimene chikugwirizanitsa apa
Related changes
Upload file
Zambiri za tsamba
Get shortened URL
Download QR code
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local getArgs = require('Module:Arguments').getArgs local p = {} function p._encode(sortkey) -- Protect against sortkey nesting. -- Example: {{sort|{{dts|2013|07|07}}|{{dts|1990|12|01}}}} if string.find(sortkey, "sortkey") or string.find(sortkey, "data-sort-value") then return ""; end return mw.text.encode(sortkey) end function p.encode(frame) local args = getArgs(frame); return p._encode(args[1] or "") end local function valid_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"). if type(num) == 'number' and tostring(num):find('n', 1, true) == nil then return true end end function p._sortKeyForNumber(value) local sortkey if not valid_number(value) then if value < 0 then sortkey = '1000000000000000000' else sortkey = '9000000000000000000' end elseif value == 0 then sortkey = '5000000000000000000' else local mag = math.floor(math.log10(math.abs(value)) + 1e-14) local prefix if value > 0 then 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 return sortkey; end function p.sortKeyForNumber(frame) local args = getArgs(frame); return p._sortKeyForNumber(args[1] or "") end return p
Summary:
By saving changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Preview page with this template
Wikidata entities used in this page
Module:Sortkey
: Sitelink, Description: en
Template used on this page:
Module:Sortkey/doc
(
edit
)
Fufuzani
Fufuzani
Editing
Module:Sortkey
Add languages
Add topic