Difference between revisions of "Template:Number table sorting/doc"
[unchecked revision] | [unchecked revision] |
(→Limitations) |
(→More examples) |
||
Line 45: | Line 45: | ||
|- | |- | ||
| {{nts|between 2 and 3|debug=yes}} | | {{nts|between 2 and 3|debug=yes}} | ||
+ | |- | ||
+ | | {{nts|approx. 10|debug=yes}} | ||
|- | |- | ||
| {{nts|-5|debug=yes}} | | {{nts|-5|debug=yes}} | ||
Line 94: | Line 96: | ||
| {{nts|.12345678|debug=yes}} | | {{nts|.12345678|debug=yes}} | ||
|- | |- | ||
− | | {{nts|.02345678|debug=yes}} | + | | {{nts|0.12345678|debug=yes}} |
+ | |- | ||
+ | | {{nts|0.02345678|debug=yes}} | ||
+ | |- | ||
+ | | {{nts|0.00345678|debug=yes}} | ||
|- | |- | ||
− | | {{nts|. | + | | {{nts|0.00045678|debug=yes}} |
|- | |- | ||
− | | {{nts|. | + | | {{nts|0.00005678|debug=yes}} |
|- | |- | ||
− | | {{nts|. | + | | {{nts|0.00000678|debug=yes}} |
|- | |- | ||
− | | {{nts|. | + | | {{nts|0.00000078|debug=yes}} |
|- | |- | ||
− | | {{nts|. | + | | {{nts|0.00000008|debug=yes}} |
|- | |- | ||
| {{nts|.00000008|debug=yes}} | | {{nts|.00000008|debug=yes}} |
Revision as of 05:49, 5 September 2010
This is a documentation subpage for Template:Number table sorting. It contains usage information, categories and other content that is not part of the original template page. |
Number table sorting/doc stands for Template:Buumber Template:Buable Template:Buorting and is used to display numbers with thousands separator in a sortable table and have them numerically sorted in alphabetic sort mode. It is applied to all numbers of a column, in cases where numeric sort mode does not work or is not desired.
Contents
Purpose
If some table cells in a column contain text after the number, or if the numbers are preceded by some fixed text other than a currency symbol, alphabetic sorting mode is needed.
Also, formerly, for table sorting to function correctly, numbers had to be entered with not more than one thousands separator. As a workaround alphabetic sorting mode was applied, and the numbers provided with a hidden part so that alphabetic sorting corresponded with numeric sorting. Since a mix in one column of numbers formatted for alphabetic sorting and plain numbers does not allow proper sorting, adding a number in an existing table may require putting it in the format used in that column.
Method
This template automatically creates hidden code like <span style="display:none">&0000000123456789.001230</span>
before the actual displayed number. The preceding ampersand forces the sorting routine to use text sort. The routine sorts the total text without the tags, which corresponds to numeric sorting due to the leading zeros.
Limitations
- Negative numbers do not sort correctly with this template: while they correctly come at the low end, mutually they are sorted in reverse order (i.e., in the order of the absolute value).
- The maximum number is 1×10Template:Val/delimitnum. While larger numbers correctly come at the high end, they are mutually sorted alphabetically. When using a consistent non-scientific notation they still sort correctly.
- There is a maximum of 6 digits after the decimal separator. When using a consistent non-scientific notation numbers with more than 6 digits after the decimal separator still sort correctly.
- In the case of text before a number, the entry is positioned like 1×10Template:Val/delimitnum. If there are more of such entries they are mutually sorted alphabetically (primarily based on the text).
Parameters
The template has only one parameter: a real number without thousand separators.
Example
{{Nts|123456789.00123}}
expands to
<span style="display:none">&0000000123456789.001230</span> 123,456,789.00123
which is rendered as
123,456,789.00123Debug option
More examples
Below are more examples, also illustrating the limitations mentioned above.
Note: Javascript sorting order: &+,-.0123456789Ee~
sortkey and number |
---|
2999500000000000000♠−5 |
2999600000000000000♠−4 |
2998270000000000000♠−73 |
2998330000000000000♠−67 |
7005123456000000000♠1.23456×10 5 |
7016203456789012345♠20,345,678,901,234,567.12345678 |
7017100345678901234♠100,345,678,901,234,567.12345678 |
7015123456789012345♠1,234,567,890,123,456.12345678 |
7014234567890123456♠234,567,890,123,456.12345678 |
7013345678901234561♠34,567,890,123,456.12345678 |
7012456789012345612♠4,567,890,123,456.12345678 |
7011567890123456123♠567,890,123,456.12345678 |
7010678901234561234♠67,890,123,456.12345678 |
7009789012345612345♠7,890,123,456.12345678 |
7008890123456123456♠890,123,456.12345678 |
7007901234561234567♠90,123,456.12345678 |
7005123456123456780♠0,123,456.12345678 |
7005123456123456780♠123,456.12345678 |
7004234561234567799♠23,456.12345678 |
7003345612345678000♠3,456.12345678 |
7002456123456780000♠456.12345678 |
7001561234567800000♠56.12345678 |
7000612345678000000♠6.12345678 |
6999123456780000000♠.12345678 |
6999123456780000000♠0.12345678 |
6998234567800000000♠0.02345678 |
6997345678000000000♠0.00345678 |
6996456780000000000♠0.00045678 |
6995567800000000000♠0.00005678 |
6994678000000000000♠0.00000678 |
6993780000000000000♠0.00000078 |
6992800000000000000♠0.00000008 |
6992800000000000000♠.00000008 |
5000000000000000000♠0 |
See also
- {{Ntsh}} - same as Nts, but does not display the number
- {{Ntsc}} - for converted units, sorts by the first number
- {{Ntss}} - same as Nts, but allows for the number to be scaled
- {{Dts}} - for sorting dates
- {{Sms}} - Probably a duplicate of {{Ntsh}}