Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Sorting sub-array in descending order using Groq in Sanity.io.

6 replies
Last updated: Mar 14, 2023
Is there a way I can sort a sub-array from my response?
Mar 14, 2023, 6:11 PM
I want the adventureBlogPosts to be sorted in descending order, however it doesn’t seem to flip order when I change “desc” to “asc”
Mar 14, 2023, 6:12 PM
still a groq noob here, but might be that you want the pipe and order() fn to live after the last curly brace that you have highlighted there - order of operations can matter sometimes on these
Mar 14, 2023, 6:52 PM
thanks User, will give it a shot now
Mar 14, 2023, 6:53 PM
❤️ that did it, would never have thought to put it there
Mar 14, 2023, 6:54 PM
thank you thank you!
Mar 14, 2023, 6:54 PM
yeah, was floating around in my head due to a part of the kap+lauren learn groq youtube playlist where they went over order of operations on some stuff, this type of thing is always so annoying and tricky with new languages but glad it worked
Mar 14, 2023, 6:56 PM

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?