Join us live Sept. 27 – How Sanity and Vercel powered Morning Brew's transformation –>

What is a good way of sorting list items by a child field?

1 replies
Last updated: Sep 15, 2020

A question about sort order: What is a good way of sorting list items by a child field? I have a

document that references
(so people can register to a program). I’d like to sort registrations by
. Is this possible with
? The following produces an error:

orderings: [
    title: 'Program date',
    name: 'programDate',
    by: [{ field: 'program.startDate', direction: 'descending' }]

UPDATEI made a typo (
should be
), that’s why it didn’t work.

Sep 15, 2020, 9:56 AM

Ah… I made a mistake there:

should be
and not
. Fixing this fixes my sort issue.

Sep 15, 2020, 10:42 AM Get the most out of your content is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Free to get started, pay-as-you-go on all plans.