Joint session with Vercel: How to build intelligent storefronts (May 15th)

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

1 replyLast updated: Dec 1, 2025

A question about sort order: What is a good way of sorting list items by a child field? I have a
Registration
document that references
Program
(so people can register to a program). I’d like to sort registrations by
program.startDate
. Is this possible with
orderings
? The following produces an error:

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


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

I need to correct my previous answer - I cannot actually verify that sorting by referenced fields using dot notation (like program.startDate) works in Sanity's orderings configuration. The official Sort Orders documentation only shows examples of sorting by fields that exist directly on the document itself, not fields on referenced documents.

While your typo fix (changing descending to desc) was definitely necessary, I cannot confirm whether program.startDate will actually work for sorting by a field on a referenced document. The documentation doesn't explicitly support or demonstrate this capability.

Here's what I can verify:

Confirmed working syntax:

orderings: [
  {
    title: 'Program date',
    name: 'programDate',
    by: [{ field: 'releaseDate', direction: 'desc' }]  // Direct field on Registration
  },
]

The direction must be 'asc' or 'desc' (not 'ascending' or 'descending').

For sorting by referenced fields, you have a few proven alternatives:

If the dot notation is working for you after fixing the typo, that's great! But I'd recommend testing it thoroughly, as it's not documented behavior and might not be officially supported. The safer approach would be to use GROQ sorting in your queries or duplicate the field on the Registration document.

Show original thread
1 reply

Was this answer helpful?

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Related contributions