Help:Sortable tables: Difference between revisions

Content deleted Content added
Unsuitability of padding with no-break spaces: Shorten to "Non-breaking spaces".
Alphabetic sorting with hidden sortkey: Retitle this and adjacent subsection for clarity, and make them both children of the previous section.
Line 458:
Javascript sorting is based on the text inside and outside the tags, without the tags themselves. A hidden sortkey can be put at the start. Both in the case of alphabetic and that of numeric sorting the first parts determine the order. Both parts together are used to determine the sort mode, so for numeric sorting the whole should be a valid number.
 
===Alphabetic sorting with hidden sortkeykey===
The sortkey comes at the start and is separated from the displayed text in such a way that the latter does not affect the sorting order. For example, if a sortkey system is used where there are no blank spaces in any sortkey, then a blank space can be used for separation. If a single blank space ''is'' possible in a sortkey, two nbsps can be used. For table elements for which the text to be displayed is equal to the sortkey, no duplication is needed, of course.
 
Line 465:
Instead of "display=none" another way is using a font color equal to the background, e.g. <nowiki><font color="#f9f9f9">999</font></nowiki> gives "<font color="#f9f9f9">999</font>". With this method the hidden code can be seen in selected text (e.g. with the mouse). Also the hidden text is included when copying the rendered text. The first may be an advantage or a disadvantage, the second seems only a disadvantage. A complication is also that if a user uses a background color different from the default, the specified text color may not match it; to make sure they are the same the background color can be specified also.
 
===AlphabeticNumeric sortkeysorting forwith numerichidden sortingkey===
If one needs to use alphabetic sort mode for numbers, one can construct a hidden alphabetic sortkey for this purpose. This can be done for all numbers between -1e100 and 1e100 in arbitrary precision as follows:
*where scientific notation is used, it is normalized such that the absolute value of the mantissa is between 1 and 10; the exponent is put first