I'm simply trying to halt execution after every swap made in bubble sort so that I can see the changes, hence how can I make the function halt execution for a few seconds i.e. have a python equivalent of sleep() function in reactjs
bubbleSort(){
const {array} = this.state;
for(let i = 0; i < array.length; i++){
for(let j = 0; j < array.length-i-1; j++){
if(array[j] > array[j+1]){
let temp = array[j];
array[j] = array[j+1];
array[j+1] = temp;
//halt for an interval on n seconds
}
}
}
}