# Sorting

You aren’t long into a computer programming course before you find yourself teaching or learning how to sort the contents of a list. Any computer science teacher will do the standards…

• sort an unordered collection of numbers in ascending or descending order
• sort a class list alphabetically
• sort groups of containers based on their capacity

While a quick read makes it sound like these are entirely different things and certainly they are to the eyes of a student learning to sort, they really aren’t. Computer wise, they all rely on being in some sort of order. Numbers or letters wouldn’t be terribly useful if they ultimately couldn’t be put in order.

The whole concept of sorting can be pretty academic or can actually be fun, particularly if you involve some activity or visualization to go with it. I’ve mentioned before how I actually have students “discover” an algorithm with 10 cards with the digits 0-9 on them, 10 people, and 11 chairs. The only rule is that only one person is allowed to stand up at a time.

The longer students stay in computer science, the more different sorting algorithms they learn. Over the years, I’ve taught many but truth be told, if I have to write a sort, the Bubble Sort and Selection Sort are the only ones that I have committed to memory. It’s actually one of those things that are easily found by any credible search engine.

Going back to visualizations, this a very interesting display.

Sorting Algorithms Animations

If you like moving things to clarify concepts, you’ll love this.

You’ll see a number of play buttons on the page and can play the animation by sort, by data type, or hey, all at once. Beyond the concept of learning how a sort works, knowing a number of different algorithms, the data, and the efficiency all become part of the learning package.

You’ve got to love something that makes a programming concept fun to visualize.

## Author: dougpete

The content of this blog is generated by whatever strikes my fancy at any given point. It might be computers, weather, political, or something else in nature. I experiment and comment a lot on things so don't take anything here too seriously; I might change my mind a day later but what you read is my thought and opinion at the time I wrote it! My personal website is at: http://www.dougpeterson.ca Follow me on Twitter: http://www.twitter.com/dougpete I'm bookmarking things at: http://www.diigo.com/user/dougpete

## 3 thoughts on “Sorting”

1. Doug, I keep thinking about the math expectations around sorting. I don’t know how many still exist with the new curriculum document, but I have to wonder now if coding and sorting could connect somehow. Even if not connected with coding, you’re making me think of when I really use sorting: for data in a spreadsheet. Hmmm … And to think that no matter what grade I’ve taught, I’ve never used this example with kids. I wonder if I’m alone in this. Seems like it’s time to make a change.

Aviva

Like