User talk:Gearzein/Sandbox

Table sorting
The problem illustrated in the "control" table may very well be a bug; according to wikipedia:Help:Sorting, cells in columns sorted numerically whose contents evaluate to NaN are supposed to be treated as -∞ rather than zero.

Anyway, for a slightly more elegant (if still brute force) solution, see the bottom of the sandbox. The table there makes use of the  attribute to cause all "empty" cells to be treated as an arbitrarily low number (I chose -100) and thus always display at the bottom of the table.

71.161.110.46 08:58, 13 February 2015 (UTC)
 * Thanks for pointing this out to me. This'll reduce a lot of clumsy forced alphabetization into a quick find-and-replace. Just as a guess, the "-" characters used to fill empty spots on the tables were making it read alphabetically, hence the 10/5/7 sorting; presumably "+" is considered to come before "-" alphabetically, causing "-20" to come last. Or something. Why using data-sort-type=number in the column header causes it to read both spaces and "-" as zeroes is beyond me, but at the moment your solution is probably the wiki's best bet.
 * The whole thing's protected anyway, so as long as it works on the page, the end user doesn't have to know how silly it looks under the hood. Thanks for the assist, and keep up the good work. Gearzein (talk) 12:33, 13 February 2015 (UTC)
 * I may have been too hasty in assuming that there could be a bug involved in this issue; according to the Wikipedia page linked above, part of the criterion for cells' contents to be treated as numerical data is for "the first non-blank element [to consist] of just digits..."-"...[or] a string consisting of "+", "-", digits". To me, this says that "-" is considered to be numerical data, and that almost the entire table was thus being treated as numerical from the start. As a result, I suppose "-" was being treated as a negative sign rather than a hyphen, which I guess would cause the affected cells to be assumed to be -(0) or something.


 * However, your guess (that "+" comes before "-" alphabetically) is correct according to mw:Help:Sorting, so it looks like the results would have been the same whether the data was being treated as numbers or text. This does bring up another potential solution in having all of the empty cells use another placeholder symbol (see the sandbox; testing with no changes to the control table other than the "-" symbols being replaced with "=" solved the problem)...but then, no other symbol really looks as good aesthetically as "-", so I dunno.


 * 71.161.95.183 23:09, 13 February 2015 (UTC)