function onButtonClick() { var fruits = ['Banana', 'Orange', 'Apple', 'Mango']; alert(fruits.sort(sortDescending)); } function sortAscending(a, b){ if (a == b) return 0; if (a > b) return 1; return -1; } function sortDescending(a, b){ return -1 * sortAscending(a, b); }
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.