Friday Puzzler: Sort Type

This post is more than 2 years old.

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.


Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate for HERE Technologies. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA