πŸ‘€ Our most exciting product launch yet πŸš€ Join us May 8th for Sanity Connect

Use GROQ to order by last name in where name is stored as full name

By Sigurd Heggemsnes

Order by last name

Model

{
  type:"document",
  name:"person",
  fields: [
    {
      name:"name",
      type:"string
    }
  ]
}

Query

*[_type == "person"]|order(string::split(name, " ")[-1], asc)[0...12]

This example is based on having a "person" document type

Contributor

Other schemas by author