In my Angular project, I am working on a sorting visualizer using the chart.js bar chart. Currently, I am focusing on visualizing bubble sort and I want to incorporate a delay in each iteration of the inner loop. I assume you are familiar with the loop structure of bubble sort. My plan is to compare the elements, then call a custom draw function to update the chart, and finally introduce a 0.5 second delay before moving on to the next iteration.
for (let i = 0; i < this.data.length; i++) {
for (let j = 0; j < this.data.length; j++) {
//comparison
this.draw();
// 0.5 SECOND DELAY
}
}