Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sorted plain list
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!
-- This module generates a sorted plain list -- It was created as a modification of [[Module:Sort]] local p = {} local lang = mw.getContentLanguage() local ubl = require('Module:List').unbulleted local function transformstring(s) local a = mw.text.trim(s) a = mw.ustring.gsub(a, '%[%[[^%[%]<>|][^%[%]<>|]*|([^%[%]<>|][^%[%]<>|]*)%]%]', '%1') a = mw.ustring.gsub(a, '%[%[([^%[%]<>|][^%[%]<>|]*)%]%]', '%1') a = mw.ustring.gsub(a, '[%s%β]', 'AA' ) a = mw.ustring.gsub(a, '([%D])([%d])$', '%10%2') return a end -- This function was copied/modified from [[Module:Wikidata]] local function getValue(frame, propertyID) local entity = mw.wikibase.getEntityObject() local claims if entity and entity.claims then claims = entity.claims[propertyID] end if claims then -- if wiki-linked value output as link if possible if (claims[1] and claims[1].mainsnak.snaktype == "value" and claims[1].mainsnak.datavalue.type == "wikibase-entityid") then local out = {} for k, v in pairs(claims) do local sitelink = mw.wikibase.sitelink("Q" .. v.mainsnak.datavalue.value["numeric-id"]) local label = mw.wikibase.label("Q" .. v.mainsnak.datavalue.value["numeric-id"]) if label == nil then label = "Q" .. v.mainsnak.datavalue.value["numeric-id"] end if sitelink then out[#out + 1] = "[[" .. sitelink .. "|" .. label .. "]]" else out[#out + 1] = label end end return out else -- just return best values return { entity:formatPropertyValues(propertyID).value } end else return {""} end end function p.asc(frame) local items if frame.args.propertyID then items = getValue(frame, frame.args.propertyID) else items = mw.text.split( frame.args[1] or '', frame.args[2] or ',', true) end if (frame.args['type'] or '') == 'number' then table.sort( items, function (a, b) return ((lang:parseFormattedNumber(a) or math.huge) < (lang:parseFormattedNumber(b) or math.huge)) end ) else table.sort( items, function (a, b) return mw.text.trim(a) < mw.text.trim(b) end ) end return ubl(items) end function p.desc(frame) if frame.args.propertyID then items = getValue(frame, frame.args.propertyID) else items = mw.text.split( frame.args[1] or '', frame.args[2] or ',', true) end if (frame.args['type'] or '') == 'number' then table.sort( items, function (a, b) return ((lang:parseFormattedNumber(a) or math.huge) > (lang:parseFormattedNumber(b) or math.huge)) end ) else table.sort( items, function (a, b) return mw.text.trim(a) > mw.text.trim(b) end ) end return ubl(items) end function p.ascd(frame) local items if frame.args.propertyID then items = getValue(frame, frame.args.propertyID) else items = mw.text.split( frame.args[1] or '', frame.args[2] or ',', true) end if (frame.args['type'] or '') == 'number' then table.sort( items, function (a, b) return ((lang:parseFormattedNumber(a) or math.huge) < (lang:parseFormattedNumber(b) or math.huge)) end ) else table.sort( items, function (a, b) return ( transformstring(a) < transformstring(b) ) end) end return ubl(items) end function p.descd(frame) local items if frame.args.propertyID then items = getValue(frame, frame.args.propertyID) else items = mw.text.split( frame.args[1] or '', frame.args[2] or ',', true) end if (frame.args['type'] or '') == 'number' then table.sort( items, function (a, b) return ((lang:parseFormattedNumber(a) or math.huge) > (lang:parseFormattedNumber(b) or math.huge)) end ) else table.sort( items, function (a, b) return ( transformstring(a) > transformstring(b) ) end) end return ubl(items) end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Basepage subpage
(
edit
)
Template:Lua
(
edit
)
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Ombox
(
edit
)
Template:Para
(
edit
)
Module:Arguments
(
edit
)
Module:List
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Message box/ombox.css
(
edit
)
Module:Sorted plain list
(
edit
)
Module:Sorted plain list/doc
(
edit
)
Module:TableTools
(
edit
)
Module:Yesno
(
edit
)