var cocktail; var gnome; var numbers = Array(); function populate(length, min_value, max_value) { for(var input = 0; input < length; input++) { numbers[input] = Math.round((max_value - min_value) * Math.random() + min_value); } } function reset() { cocktail.reset(); gnome.reset(); } function sort() { cocktail.sort(); gnome.sort(); } function repopulate() { populate(25, -100, 100); cocktail.copy(numbers); gnome.copy(numbers); } function go() { populate(25, -100, 100); cocktail = new sort_array('cocktail', numbers.length); cocktail.copy(numbers); cocktail.sort = cocktail_sort; gnome = new sort_array('gnome', numbers.length); gnome.copy(numbers); gnome.sort = gnome_sort; document.getElementById('populate').onclick = repopulate; document.getElementById('reset').onclick = reset; document.getElementById('sort').onclick = sort; }