## Friday, October 14, 2011

### Let's Sort This Out, Part V

We have focused on sorting this week. That means putting data into different arrangements to see if it helps us to analyze and understand what we are working with.

I checked with my spreadsheet documentation to see how it can do sorting. Here's what it can do - notice that your software may vary:

I scanned a Wikipedia page on sorting algorithms which caused me to doze at my desk. If you are a programmer you may wish to check it out. All others, avoid it!

I located a page with tips for solving sorting challenges using Microsoft Excel software  (not to be confused with Excel Math, the elementary math curriculum that we publish). Here are some examples:
• Automatically Sorting When you enter text and you want the data to sort itself automatically.
• Ignoring Words when Sorting If you sort movie, book, or product titles, you may want to ignore certain words when sorting.
• Incomplete or Bad Sorting Using sorting tools can jumble the data; how do you repair it?
• Sorting by Colors If you need to sort based on the color of the cell or the data, it's possible!
• Sorting Graphics It seems crazy, but you can sort images that appear in a spreadsheet.
• Sorting Dates by Month Sorting by dates is easy, but it's tricky to sort by months.
• Ascending & Descending Sorting Rules When you sort, programs normally work in a certain pattern or sequence; you need to know this when sorting combined letters and numbers.
I was amazed to see that it's possible to sort on colors. My wife and I had a serious discussion about what that means, right after we started trying to choose paint colors for our kitchen.

Do you sort on the numerical values of the colors, their PMS numbers, the alphabetical names of the colors, what? So I went on a search.
• I found a discussion where someone suggested "You're sorting by redness, then green-ness, then blueness. Probably you're going to have to convert the colors to HSV, and sort by H first (hue) then S (saturation) then V (value/brightness."
• Next guy said "To make the colors transition with the best smoothness, you have to solve a traveling-salesman problem: Find the distance between each two colors (square root of the sum of the squares of the red, green, and blue differences), lay them out in a big table, and find the shortest path that visits each one. The bad news is that this belongs to the hardest known category of computable problems..."
• I found elementary math here "you're trying to map three dimensional values onto one dimension. This results in wave patterns - which frankly is not very satisfactory, as anyone who spent way too much time in kindergarten trying to organize a big box of crayons can tell you!"
• The most useful comment I found said  "Colors don't have a canonical linear (fixed) order so the first thing you have to decide is how you want them sorted. If you can't describe how you would do it by hand, you're out of luck when it comes to programming!"
As an example to prove this, my wife and I have a very long shelf at our house, and on it are many model cars. A few weeks ago we sorted them in color order - black on one end and white on the other. But I've noticed when one of us is on the telephone in that room, we tend to pick up a few cars and rearrange them, improving the color sort. There is no perfect order, and these aren't "theoretical" colors, they are real paint on real objects.

Sorting can be one of the most difficult assignments, with many dimensions. We tackle it in Excel Math. Even though they are young, it doesn't mean that what they are learning is easy!

Here's a site that creates color sorting practice worksheets for kindergarteners, try it yourself!