Monday, July 8, 2013

Google Spreadsheet sort in case-sensitive ascending order


( by Nighthound )

I have a list of text entries in a column that I wish to sort in case-sensitive ascending order, with capital letters before small letters.

For example, I want to sort:


and get:


However, Google Sheets ignores case when sorting in ascending order and gives this result:


 What can I do to achieve my desired result?


Your desired result could be achieved in many ways, but the easiest and according to me the best way is to have a custom function.
Custom function means you have to built the function of your own in the scripts. And I have coded a script, and here it is:

function ksort()
  if (arguments.length < 1)
    return "#NA Please input range to sort";
  else if (arguments.length > 1)
    return "#NA Input Can't be more than one arguement";
  else if(arguments[0][0].length == 1)
    return arguments[0];
    return arguments[0].sort();

Now, put the above code in your script editor and you are done.

Have a look at the following screenshot:

Now put the formula as:

that is:
(for the example shown above in the screenshot).

And If you are not much familiar with scripts then check out the following link: 

I hope the above solution will help you, and if you need more help then please do comment below on this blog itself, I will try to help you out.

I also take up private and confidential projects:
If this blog post was helpful to you, and if you think you want to help me too and make my this blog survive then please donate here: 


No comments:

Post a Comment