SO SATISFYING
ยทUpdated:
·

If you're not a computer scientist, you probably can't think of that many methods for sorting information. If you are a computer scientist, you know that there are tons of different sorting algorithms, each with its own advantages and disadvantages. Either way, you'll probably like a collection of visualizations of how various sorting algorithms work that a Redditor called morolin posted this week. With simplicity and elegance, these GIFs demonstrate all the different strategies that can be used to move pieces of information from one place to another in a way that will make you go, "Ohhh, I get it now."

For instance, here's morolin's visualization of bubble sort, which "repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order," according to Wikipedia. "The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted.โ€‹"

 

This visualization is for insertion sort, which moves each element on a list into the right place one at a time. Morolin writes, "To me, insertion looks more like bubbles rising up than bubble sort."

 

Shellsort "starts by sorting pairs of elements far apart from each other, then progressively reducing the gap between elements to be compared," according to Wikipedia.

 

There are way more sorting algorithms visualized in morolin's Imgur album, which is well worth checking out in full. The real fun happens when morolin stages races among different algorithms to see which can sort data the fastest.

 

Better luck next time, cocktail sort. 

[via Reddit]

Want more stories like this?

Every day we send an email with the top stories from Digg.

Subscribe