Sorting

To iterate through arrays, use attributes of objects instead of the reserved iterator i . It can be used to sort data directly in the template.

In the following example, all cars are sorted by "power" in ascendant order (descendant order is not possible for the moment).

Data

{
  "cars" : [
    { "brand" : "Lumeneo" , "power" : 3 },
    { "brand" : "Tesla"   , "power" : 1 },
    { "brand" : "Toyota"  , "power" : 2 }
  ]
}
Cars

{d.cars[power].brand}

{d.cars[power+1].brand}

Last updated