ଛାଞ୍ଚ:Number table sorting

ଉଇକିପିଡ଼ିଆ ରୁ
Documentation icon Template documentation[view] [edit] [history] [purge]

This template 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.

The supplied input numbers should not have thousands separators. Apart from the added thousands separators the numbers are formatted like supplied (scientific notation or not, leading and trailing zeros, and a zero before the decimal point or not). This formatting does not affect the sorting order except for numbers not satisfying the limitations mentioned below.

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 × 10୧୬. While larger numbers correctly come at the high end, they are mutually sorted alphabetically.
  • 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. They sort correctly with respect to 0 if they are written with the zero before the decimal point.
  • In the case of text before a number, the entry is positioned like 1 × 10୧୬. If there are more of such entries they are mutually sorted alphabetically (primarily based on the text).

Parameters[ସମ୍ପାଦନା]

The template has only one required parameter: a real number without thousand separators.

Optional parameters
  • debug - To show the sort key, use |debug=yes.
    "{{nts|123456789.00123|debug=yes}}" gives "&0000000123456789001230୧୨,୩୪,୫୬,୭୮୯.୦୦୧୨୩" [୧]
  • prefix - To add a prefix to the displayed number, use |prefix=some prefix
    "{{nts|123456789.00123|prefix=approx. }}" gives "&0000000123456789001230approx. ୧୨,୩୪,୫୬,୭୮୯.୦୦୧୨୩" [୨]

Example[ସମ୍ପାଦନା]

{{Nts|123456789.00123}}

expands to

 <span style="display:none">&0000000123456789.001230</span> 123,456,789.00123 

which is rendered as &0000000123456789001230୧୨,୩୪,୫୬,୭୮୯.୦୦୧୨୩

More examples[ସମ୍ପାଦନା]

Below are more examples, also illustrating the limitations mentioned above.

Note: Javascript sorting order: &+,-.0123456789Ee~

sortkey and number
&ପ୍ରକାଶନରେ ଅସୁବିଧା: ଅଜଣା ଶବ୍ଦ "between"b
&ପ୍ରକାଶନରେ ଅସୁବିଧା: ଅଜଣା ଶବ୍ଦ "approx"ap.
&-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-5000000-୫
&-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-4000000-୪
&-1-1-1-1-1-1-1-1-1-1-1-1-1-1-8-3000000-୭୩
&-1-1-1-1-1-1-1-1-1-1-1-1-1-1-7-7000000-୬୭
&0000000000123456000000୧୨୩.୪୫୬
&~୨୦,୩୪,୫୬,୭୮,୯୦,୧୨,୩୪,୫୬୭.୧୨୩୪୫୬୭୮
&~୧,୦୦,୩୪,୫୬,୭୮,୯୦,୧୨,୩୪,୫୬୭.୧୨୩୪୫୬୭୮
&1234567890123456000000୧,୨୩,୪୫,୬୭,୮୯,୦୧,୨୩,୪୫୬.୧୨୩୪୫୬୭୮
&0234567890123456125000୨୩,୪୫,୬୭,୮୯,୦୧,୨୩,୪୫୬.୧୨୩୪୫୬୭୮
&0034567890123456125000୩,୪୫,୬୭,୮୯,୦୧,୨୩,୪୫୬.୧୨୩୪୫୬୭୮
&0004567890123456123046୪୫,୬୭,୮୯,୦୧,୨୩,୪୫୬.୧୨୩୪୫୬୭୮
&0000567890123456123413୫,୬୭,୮୯,୦୧,୨୩,୪୫୬.୧୨୩୪୫୬୭୮
&0000067890123456123458୬୭,୮୯,୦୧,୨୩,୪୫୬.୧୨୩୪୫୬୭୮
&0000007890123456123456୭,୮୯,୦୧,୨୩,୪୫୬.୧୨୩୪୫୬୭୮
&0000000890123456123456୮୯,୦୧,୨୩,୪୫୬.୧୨୩୪୫୬୭୮
&0000000090123456123456୯,୦୧,୨୩,୪୫୬.୧୨୩୪୫୬୭୮
&0000000000123456123456୦୧,୨୩,୪୫୬.୧୨୩୪୫୬୭୮
&0000000000123456123456୧,୨୩,୪୫୬.୧୨୩୪୫୬୭୮
&0000000000023456123456୨୩,୪୫୬.୧୨୩୪୫୬୭୮
&0000000000003456123456୩,୪୫୬.୧୨୩୪୫୬୭୮
&0000000000000456123456୪୫୬.୧୨୩୪୫୬୭୮
&0000000000000056123456୫୬.୧୨୩୪୫୬୭୮
&0000000000000006123456୬.୧୨୩୪୫୬୭୮
&0000000000000000123456.୧୨୩୪୫୬୭୮
&0000000000000000123456୦.୧୨୩୪୫୬୭୮
&0000000000000000023456୦.୦୨୩୪୫୬୭୮
&0000000000000000003456୦.୦୦୩୪୫୬୭୮
&0000000000000000000456୦.୦୦୦୪୫୬୭୮
&0000000000000000000056୦.୦୦୦୦୫୬୭୮
&0000000000000000000006୦.୦୦୦୦୦୬୭୮
&0000000000000000000000୦.୦୦୦୦୦୦୭୮
&0000000000000000000000୦.୦୦୦୦୦୦୦୮
&0000000000000000000000.୦୦୦୦୦୦୦୮
&0000000000000000000000

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}}