has anyone figured out a way to sort lists of content in the studio? i'd love a drag and drop if possible

3 replies
Last updated: Jan 13, 2021
has anyone figured out a way to sort lists of content in the studio? i'd love a drag and drop if possible
AI Update

Yes! The official @sanity/orderable-document-list plugin is exactly what you're looking for. It gives you drag-and-drop functionality right in the Studio editing interface.

Installation

Just run:

npm i @sanity/orderable-document-list

How it works

The plugin manages document order using an orderRank field behind the scenes. The great thing is that this ordering persists and can be queried from your frontend applications, so the order you set in Studio actually reflects on your live site.

Why this is better than alternatives

Before this plugin, people had to use workarounds like:

  • Creating wrapper documents with arrays of references
  • Adding manual "order" or "importance" number fields
  • Building custom singleton documents to manage ordering

Those approaches still work for complex scenarios (like when you need different ordering schemes in different contexts), but for straightforward "I want to drag and drop my content into order" use cases, the orderable-document-list plugin is much cleaner.

Important note

Keep in mind that the sort orders you can configure in Studio's desk structure are just for organizing how you see documents in the Studio interface—they don't automatically affect your API queries. The orderable-document-list plugin bridges that gap by giving you ordering that actually flows through to your frontend.

The plugin works best for small to medium-sized document collections where manual ordering makes sense. For huge datasets, you might want to stick with query-based sorting instead.

Check out the GitHub repo for implementation details and the orderRankField configuration options!

that's exactly what i need. thank you
user A
!
that's exactly what i need. thank you
user A
!

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.

Was this answer helpful?