Unlock seamless workflows and faster delivery with our latest releases – get the details

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