BubbleSort Visualization (want to slow it down)


I want to make a visualization of BubbleSort and make rectangles move to show the sorting. My code works “kind off” https://editor.p5js.org/Lillbre/sketches/HkkBABreN but I would love if every move could be seen more slowely. Does anyona have any suggestions ( I need newbeel-anguage to understand :confused:


It is not easy to synchronize the sort with a visual display, I have tried in the past but found the best way was to let the sort happen at normal speed but remember which elements are being swapped, something like a linked list which you can iterate through forwards and backwards.

Then for the display you can just iterate over the list at any speed you want.

This video is of a Processing sketch I created for visualising a variety of sort algorithms where I used this approach.


Thank you quark! I’ll try that. Great video!


Possibly of interest: a related recent discussion of sort visualization –