-
var j = 0;
function bubbleSort() {Timer = setInterval(function() { if (data.length - 1 < 1) { clearInterval(Timer); }; if (data[j] > data[j + 1]) { var swap = data[j]; data[j] = data[j + 1]; data[j + 1] = swap; console.log(j); show(); }; if (j == data.length-2) { j = 0; } else { j++; }; }, 2);
}
-
var j = 0;
function bubbleSort() {
Timer = setTimeout(function() { if (data.length - 1 < 1) { clearTimeout(Timer); }; if (data[j] > data[j + 1]) { var swap = data[j]; data[j] = data[j + 1]; data[j + 1] = swap; console.log(j); show(); }; if (j == data.length-2) { j = 0; } else { j++; }; bubbleSort() }, 2);
}
你执行bubbleSort()了吗