
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeGreat question! You've actually discovered a common gotcha with GROQ queries and ordering fields. The solution you found with Geoff's help is exactly right, and it's worth explaining why this happens.
When you use the order() function in GROQ, the ordering happens on the backend, but GROQ doesn't automatically include the field you're ordering by in your projection. This is particularly important with the Orderable Document List plugin, which uses a special orderRank field to maintain custom ordering.
The orderRank field exists in your documents and GROQ can use it for sorting, but if you don't explicitly include it in your projection, it won't be returned in the results. This can cause issues with:
orderRank in your projection, you might not see consistent orderingorderRank, they can't detect that ordering has changedYou need to include the orderRank field (or whatever ordering field your schema uses) in your projection, not just in the order() function:
// ❌ Won't reliably reflect order changes
*[_type == "myDocument"] | order(orderRank) {
_id,
title,
// orderRank not included
}
// ✅ Properly includes ordering field
*[_type == "myDocument"] | order(orderRank) {
_id,
title,
orderRank // Include this!
}This ensures that:
As noted in the GROQ pipeline components documentation, the order component sorts array elements, but projections define which fields to return. These are separate operations, and the order component doesn't automatically modify your projection to include the ordering field.
Thanks for posting your solution as an edit—this will definitely help others who run into the same issue with the Orderable Document List plugin or any custom ordering fields!
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