All about the Bubble Sorting Algorithm
Micro-optimizations #3

A fond believer in learning by doing. Loves to try out new languages in the world of computing
Want to optimize your JS-code(s)? Welp, I've got you covered! https://hasty.dev 🧑💻
Want to tweet your commits? https://gitbird.dev 🐦 It's dead I think, honestly, I haven't been keeping up with the death of the blue-bird-site 🤐
Bubble Sort
What
The Bubble Sort is - of cause - an sorting algorithm. It's a simple one of it's kind, as you'll later see.
If you in the wild, wild west of CompSci sees an alorithm called Sinking Sort, it'll look a lot like the Bubble Sort, and really, it is the same thing. These are sometimes refered to as one or the other.
A Bubble Sort is not nearly as perfomant as some of its successors - and is mainly used as an educational algorithm nowadays.
Performance
As I mentioned, Bubble Sort is definitely not one of the fastest sorting algorithms out there, meaning its O-notion is O(n^2). which is never too good. Meaning it's slow.
Why
Why would you use the Bubble Sort then? Well, it's super easy to implement, which is also why people use it, and learn from it as - again - it's a great starting point.
Try
Below is an embed from hasty.dev, this is interactive. Try it yourself and check if you can speed up the Bubble Sort!
{ Best, Mads Bram Cordes }




