I want to add the currency sign to my number while making the value remain sortable as a number in my Bootstrap Table (line 30-34; column 4 in the table):
for (var p=0; p<variable_data.length; p++){
try{
variable_data[p]["4"] = "$" + Math.round(variable_data[p]["4"])
} catch(e){ }
}
http://jsfiddle.net/mademoiselletse/s0d1xgzt/
The values with the '$' attached are sorted as strings instead of numbers. All the currency sorting problems I found online pertain to the DataTable and tablesorter() plugins. Is there a quicker fix to the problem than installing more jQuery plugins?
Thank you very much for your help!
Check the custom example here
You need to send a
data-sorter function
that removes the $ from your string and then compares it as numbers.