Sorting nested tables?

I see you can sort by 1:1 table fields, but how do you sort a nested table? For example if you have a list of people, and each person has a list of cars:

{
  personList {
    items {
      cars {
        items {
          vin
        }
      }
    }
  }
}

How would you sort the cars data by vin?

Hello @mike_ekim1024!

You can use nested sorting like in the example below:

query {
  personList {
    items {
      cars(sort: { vin: ASC)) {
        items {
          vin
        }
      }
    }
  }
}

You can see more options on sorting in api explorer’s documentation.

1 Like

Ahh, you’re right, I just didn’t have the syntax right!

Thanks!