PDA

View Full Version : sortByNumber



chic0
January 17th, 2005, 01:46 PM
Yo dudes,

I've got some trouble understanding this code to sort an Array by number:
function sortByNumber(a, b) {
return (a > b);
}
ages = [13, 52, 33, 2, 25, 14, 3, 77, 8];
ages.sort(sortByNumber);
trace(ages);

Can someone make me understand it? http://www.kirupa.com/forum/images/smilies/happy.gif

chic0
January 18th, 2005, 12:33 PM
Nobody Knows?