Content deleted Content added
tagged: needs updating to reflect which table sort features actually work as of 2009. For instance numeric sorting is broken by unicode; and smn support appears to be withdrawn. |
test smn and note that it does not work as of now |
||
Line 21:
*numeric
**criterion: the first non-blank element consists of just digits, points, commas, spaces, "+", "-", possibly followed by "e" or "E" and a string consisting of "+", "-", digits, possibly followed by "×10" and a string consisting of "+", "-", digits (the latter is for the purpose of using hidden {{mlw|Scientific_notation|E_notation|e-notation}} followed by visible superscript notation of {{mlw|scientific notation||scientific notation}}); or the element ends with "sm=n" (without the quotes; it stands for "sort mode = numeric"). (In hidden form this can conveniently be done with {{tim|smn}}.)
'''Note "sm=n" will not work if [[MediaWiki:Common.js]] does not contain the necessary ts_sort_numeric javascript function.''' As of 2009 Common.js does not have this function, so numeric sorting will not work like this. See http://meta.wikimedia.org/wiki/Template:Smn for details.
**order: if the string starts with a number (where spaces and nbsp's at the start are ignored) the order is numeric according to the first number in the string ([http://www.devguru.com/technologies/ecmascript/QuickRef/parsefloat.html parseFloat] is applied) after removing the commas, if any; if it does not (parseFloat returns [[w:NaN|NaN]]), the element is positioned like 0
:::''proposed internationalisation: in German etc., treat comma as a decimal point''
Line 33 ⟶ 36:
Text after a number (e.g. a footnote) does not affect the sorting order, if the sorting ''mode'' is numeric. However, if the number at the top has text after it, this makes the sorting mode alphabetic, unless it ends with a (typically invisible) "sm=n".
'''Note "sm=n" will not work if [[MediaWiki:Common.js]] does not contain the necessary ts_sort_numeric javascript function.''' As of 2009 Common.js does not have this function, so numeric sorting will not work like this. See http://meta.wikimedia.org/wiki/Template:Smn for details.
{|
Line 109 ⟶ 114:
|}
|}
Example table using Template:smn to force numeric sorting when the first row contains non-numeric characters after an initial number. '''Note that this will not work if [[MediaWiki:Common.js]] does not contain the necessary ts_sort_numeric javascript function.''' As of 2009 Common.js does not have this function, so the following table will not sort properly. See http://meta.wikimedia.org/wiki/Template:Smn for details.
{|class="wikitable sortable"
!first row number plus alphabetic plus '''<nowiki>{{smn}}</nowiki>'''
|-
|123.4 xyz{{smn}}
|-
|2,500,000,000
|-
|300,000,000
|-
|3,000,000 abc
|-
|5,000,000
|-
|2,000 def
|-
|4,000
|-
|9,999
|-
|800,000
|-
|900,000
|}
<br />
{|
Line 385 ⟶ 418:
The first example demonstrates that text is positioned at zero, and that e.g. e3 for 1000 is not allowed; use 1e3 instead. Using {{tim|e}}, a number in scientific notation can be displayed with a superscript, while still allowing numeric sorting (compare the method described in the next section). It also shows that "-" should be used, not "−". The first element "12 or 13 sm=n" has a visible "sm=n", although it is normally made invisible; when this element is at the top, numeric sorting mode applies.
'''Note "sm=n" will not work if [[MediaWiki:Common.js]] does not contain the necessary ts_sort_numeric javascript function.''' As of 2009 Common.js does not have this function, so numeric sorting will not work like this. See http://meta.wikimedia.org/wiki/Template:Smn for details.
The second example shows that expressions are not sorted according to their evaluated value, but according to the first number.
Line 391 ⟶ 426:
The fourth example shows again that "ca. 12" sorts at 0, as opposed to 12 with some text after it, which sorts at 12. In the latter case an invisible "sm=n" needs to be put at the end, in case such an element arrives at the top of a column, which would otherwise cause alphabetic sorting mode.
'''Note "sm=n" will not work if [[MediaWiki:Common.js]] does not contain the necessary ts_sort_numeric javascript function.''' As of 2009 Common.js does not have this function, so numeric sorting will not work like this. See http://meta.wikimedia.org/wiki/Template:Smn for details.
Sortable version of {{mlw|Template:Climate in Middle East cities}}, using smn to specify numeric sort mode:
|