
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI totally understand your client's frustration! Finding the right section in an unsorted reference list can be really tedious. Good news - you can definitely sort reference results alphabetically in Sanity Studio.
The key is to use the options.sort property on your reference field. Here's how to set it up:
{
name: 'section',
type: 'reference',
to: [{type: 'sectionType'}],
options: {
sort: [{field: 'title', direction: 'asc'}]
}
}The sort option takes an array of objects, each with a field and direction property. You can use:
direction: 'asc' - alphabetical A-Zdirection: 'desc' - reverse alphabetical Z-AYou can even sort by multiple fields:
options: {
sort: [
{field: 'category', direction: 'asc'},
{field: 'title', direction: 'asc'}
]
}The options.filter property you mentioned is separate from sorting - it's for constraining which documents appear in the reference picker. You can use both together:
{
name: 'section',
type: 'reference',
to: [{type: 'sectionType'}],
options: {
filter: '_type == "sectionType" && published == true',
filterParams: {}, // if you need parameters
sort: [{field: 'title', direction: 'asc'}]
}
}The filter property accepts a GROQ filter expression to narrow down which documents are available, while sort controls the order they appear in.
While you're improving the experience, you might also want to ensure your sections have good preview configurations. This helps your client see meaningful titles in the reference picker:
// In your sectionType schema
preview: {
select: {
title: 'title',
subtitle: 'description'
}
}This combination of alphabetical sorting via options.sort plus clear preview titles should make finding sections much easier for your client!
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store