The following code rearranges elements by the attribute "amount". How can I alter this code so the items will be reversed? Thanks.
var parent = $('#items');
var children = $('a', parent);
children.sort(function(a, b) {
return parseInt($(a).attr('amount')) - parseInt($(b).attr('amount'));
})
$.each(children, function(i, child) {
parent.append(child);
});