😎 Discover cool tips and tricks for customization in our next Developer Deep Dive virtual event - sign up now!

How to Sort a List by Lowercase in GROQ

3 replies
Last updated: Jul 1, 2021
Is there still no way to sort a list by lowercase, in GROQ? I’ve found some topics on this but they date back to 2018 and 2019. I have a list of companies where some are only uppercase and it messes with the order in which they should be presented. I would rather not do a second sorting in code.

*[_type == "company"] | order(name asc)
This returns everything in order but everything uppercase is < lowercase. So companies whose name is an abbreviation (with all capital letters) is placed in front of companies with an “actual name”.
Jul 1, 2021, 9:23 AM
Hi! You can use
order(lower(name))
.
Jul 1, 2021, 9:23 AM
Works great, thanks!
Jul 1, 2021, 9:37 AM
Super!
Jul 1, 2021, 9:47 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?