Today's Friday Puzzler should be one of the simpler ones I've posted. While having a random Facebook discussion (as if there are any other sort), the topic of sorting came up. I thought it might be an interesting challenge to write code that determines if a list of data is sorted and report back on what type of sort was being used. While there are probably more, I can think of the following sort types:

  • case sensitive text ascending
  • case sensitive text descending
  • case insensitive text ascending
  • case insensitive text descending
  • numeric ascending
  • numeric descending

And of course, it is possible there is no sort applied at all. Your goal is to take an input and report back the sort type. To make it easier for you, I've created a script that generates an array of inputs you can use for - well, inputs. I'm also looking for folks to try their hand at this in JavaScript. So to make that easier, I used the ColdFusion toScript function (y'all know about that, right?) to output JavaScript you can cut and paste.

Enjoy!