👀 Our most exciting product launch yet 🚀 Join us May 8th for Sanity Connect

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
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.
Sep 15, 2020, 9:56 AM
Ah… I made a mistake there:
direction
should be
desc
and not
descending
. Fixing this fixes my sort issue.
Sep 15, 2020, 10:42 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?