Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

136
Vistas
Sanity CMS custom sorting

I don’t know if exists some way to sorting the results by custom field. My query:

 *[_type == "movies" && actors]
{
   ..., 
   isHarryMovie: name match "Harry*" 
}

So I want to sort the results by isHarry, is it posible?

I tried something like this:

 *[_type == "movies" && actors] | order(isHarryMovie asc)
{
   ..., 
   isHarryMovie: name == "Harry" 
}

and

 *[_type == "movies" && actors] | order("isHarryMovie" asc)
{
   ..., 
   isHarryMovie: name == "Harry" 
}

but they didn't work

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can order after projecting:

*[_type == "movies"] {
  ..., 
  isHarryMovie: name match "Harry*" 
} | order(isHarryMovie desc)

This will sort by the isHarryMovie attribute that you added to each document.

But this kind of query will be forced to load all the movies, then filter, and then sort — it won't be fast. You're probably better off sorting by score:

*[_type == "movies"] | score(name match "Harry*") | order(_score desc)

This will assign a high score to any movie with name match "Harry*", and a low score to everything else.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda