Xmas Tree? Sorted!
Written by Mike James   
Sunday, 04 December 2022

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):

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..


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


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 Twitter, Facebook or Linkedin.



The Year of AI Breakthroughs 2022

Louis Bouchard has compiled a great list of research papers covering AI breakthroughs that were published during last year. His introductions and links to the papers and even to code make this a great [ ... ]

Best USA Job For 2023 - Software Developer

Software Developer is again top of the U.S. News and World Report's annual best jobs rankings and while GlassDoor's Best Paces To Work 2023 includes lots of tech companies, Meta and Apple are not [ ... ]

More News





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


Last Updated ( Sunday, 04 December 2022 )