Hello:
I am trying to sort XML data based on an attribute “price” (or p). I’m trying to sort the prices numerically so that, for example, 1230.00 does not show up before 19.00.
I have defined a preliminary price sort function as follows:
PRICE_SORT = function(a,b){
return parseFloat(a.attributes.p) > parseFloat(b.attributes.p);
}
then I sort as follows:
my_array.sort(PRICE_SORT);
How do I edit this function so that the prices will display in numerical order rather than string value order?
Thanks.