# Sorting prices in XML

**URL:** <https://forum.kirupa.com/t/sorting-prices-in-xml/200081>\
**Category:** Uncategorized\
**Created:** [September 8, 2006, 2:46pm UTC](https://forum.kirupa.com/t/sorting-prices-in-xml/200081 "2006-09-08T14:46:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thalamus](https://avatars.discourse-cdn.com/v4/letter/t/0ea827/32.png) [@thalamus](https://forum.kirupa.com/u/thalamus)\
**Post date:** [September 8, 2006, 2:46pm UTC](https://forum.kirupa.com/t/sorting-prices-in-xml/200081/1 "2006-09-08T14:46:36Z")

</div>

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.
