You can adapt the function described here: How may I sort a list alphabetically using jQuery? and just change the sort function ('<
')
In your js (highest integer to lowest):
var div = $('#foo');
var listitems = div.children('div.test').get();
listitems.sort(function (a, b) {
return (+$(a).attr('data-listing-price') > +$(b).attr('data-listing-price')) ?
-1 : (+$(a).attr('data-listing-price') < +$(b).attr('data-listing-price')) ?
1 : 0;
})
$.each(listitems, function (idx, itm) { div.append(itm); });
http://jsfiddle.net/NfVxk/