I suggest you strip the commas so they can be converted to numbers using the +
. Then you can use those numeric versions for comparison in your sorting functions.
http://jsfiddle.net/EuQTX/1/
var cols = new Array();
cols[0] = '13,000,000';
cols[1] = '-20.45';
cols[2] = '0.0';
cols[3] = '10,000';
cols[4] = '750.00';
cols[5] = '41.00';
//Removing the commas. You can add more characters to remove to the set
var pattern = /[,]/g
cols.sort(function (a,b){
//remove unwanted characters so they can be converted to numbers
a = +a.replace(pattern,'');
b = +b.replace(pattern,'');
//use the numeric versions to sort the string versions
return a-b;
});
console.log(cols);
//["-20.45", "0.0", "41.00", "750.00", "10,000", "13,000,000"]
Just a side note, you should declare arrays using the literal notation instead:
var cols = ["13,000,000", "-20.45", "0.0", "10,000", "750.00", "41.00"]