var bubble; var cocktail; 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() { bubble.reset(); cocktail.reset(); } function sort() { bubble.sort(); cocktail.sort(); } function repopulate() { populate(25, -100, 100); bubble.copy(numbers); cocktail.copy(numbers); } function go() { populate(25, -100, 100); bubble = new sort_array('bubble', numbers.length); bubble.copy(numbers); bubble.sort = bubble_sort; cocktail = new sort_array('cocktail', numbers.length); cocktail.copy(numbers); cocktail.sort = cocktail_sort; document.getElementById('populate').onclick = repopulate; document.getElementById('reset').onclick = reset; document.getElementById('sort').onclick = sort; }