Xmas Tree? Sorted!
Written by Mike James   
Thursday, 25 December 2025

Yes I know we have all seen enough visualizations of sorting algorithms to last a lifetime - which is how long a bubble sort generally takes. But it's the holiday season and sorting is one programmer way to create a tree.

The idea, visualized here by CompilerStuck, is horribly simple and only raises the question of why we have had wait so long to see it. Take an image of a stylized xmas tree , shuffle the image rows that make it up and then show how a sorting algorithm unshuffles it. It's fun and even slightly educational.

Watch the first one because its a quicksort and none of us understand a quicksort...

There is a list of sorts in the comments and you can go to any of them by clicking on a link. Some of them, you may need to lookup. To save you time, Bogo Sort is:

while not isInOrder(deck):
    shuffle(deck)

and yes it's a "sort" of joke.

Wikipedia has brief outlines of all of the methods and there is a comparison table at the end of the video.

If you are wondering which is best then it all depends what you mean by "best" but most would opt for Quick Sort, if only because it sounds as if it should be the fastest.  What is more to the point is that there are some sorting algorithms that are really, really bad and need to be avoided - see Bogo sort..

xmastreesort

The only downside is that its written in Java - only joking after all it is a time of peace and goodwill to all computer languages.

If you've never seen them before do take a look at Sorting Algorithms As Dances and share the sorting fun with you friends at this festive season.

More Information

https://www.instagram.com/compilerstuck/

Related Articles

Sorting Algorithms As Art

Sorting Algorithms As Dances

Amazing Animated Sorting Demo

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Facebook or Linkedin.

 

Banner


AI - It's All Downhill From Here?
31/12/2025

AI is a complex beast, but it is based on some very simple and very powerful ideas that deserve to be better known as they throw much light not only on the way AI works but on the way the universe wor [ ... ]



Charles Babbage - Born This Day 154 Years Ago
26/12/2025

It is an annual I Programmer tradition to celebrate the birth of Charles Babbage, the man who invented and designed a programmable computer at the start of the Industrial Age, and who is now reco [ ... ]


More News

pico book

 

Comments




or email your comment to: comments@i-programmer.info

 

Last Updated ( Thursday, 25 December 2025 )