Forum:Problem with sortable table when using both numbers and text

I am having problems getting the automatic sortable table class to work when both numbers and text values are used into a single cell. http://deusex.wikia.com/wiki/Shop_(DX3) is the page with the problem. Please use a debug page when helping instead of editing my page.

How can I get the sorting to work correctly ("7.5" isnt higher than "37.5") so it sorts by number value instead of text value ?

Will it help if I use a math template ?


 * See how the sortable tables determine the sort mode. So for example adding this:


 * -style="display:none;"
 * !a
 * 9e99
 * 9e99
 * 9e99
 * 9e99
 * 9e99
 * 9e99
 * as the first row of your "Ammunition" table, should apply an appropriate sorting mode to each of the columns. See the example on my user page for reference. — Sovq 08:59, September 11, 2011 (UTC)

Thank you for pointing me to the sortable table help page. When I added the hidden bottom row the last 3 columns sort correctly, but column 2-4 are only sorted correctly until "@ " regardless if I use forced a-Z or numeric sorting.

It would really pain me to create a hidden sort table for (each table?) it, but currently its the only option I see. Jeahra 13:55, September 11, 2011 (UTC)


 * Before you modified it, the table on my user page was sorting columns 2-4 properly, or at least differently than it is now. I'm not sure which data you want to be sorted - the part before or after the "@"? — Sovq 14:05, September 11, 2011 (UTC)

Column 2 should sort alphanumeric including "@" but numeric afterwards. Column 3 & 4 should be all numeric like "@" wasnt there, so "1 @ 50" will come before "1 @ 150". Jeahra 15:13, September 12, 2011 (UTC)


 * There is a trick you can do, but it's a menial task. It will, however, give you the control you want. If you want 150 to come after 50, hide a 0 before the number. You can template this if need be or manually do it for each number to be sorted. Check the tables below to see the differences.


 * }
 * }
 * }


 * I know it's a pain, but it works. Rappy 01:32, September 19, 2011 (UTC)


 * Thanks for idea, its much better than a hidden sorting table. Its not a pain, but how would you template it ? Jeahra 14:49, September 21, 2011 (UTC)


 * If the table itself is generated by a template, it's quite easy to add. Either way, look into the string function. You can find more detailed information here. Simply add a sufficient PAD to a basic template. Then you can do, for example,  if you want to pad the number 32 to 5 places with 0's. In your template, you'd want to hide the padded numbers by doing... "" Feel free to ask if you wish more detailed explanations. If you attempt to fix this and are unsuccessful, please respond with links here so someone can look at your code and provide help without having to search for it. Rappy 20:02, September 21, 2011 (UTC)