Forum

Thread tagged as: Question, Problem

Sorting a Collection by Multiple Fields

What is the syntax to sort a colleciton by multiple fields? I have found an example to filter by multiple field value, so though the syntax might be similar but I can't get that to work.

Here's what I have now

perch_collection('Tours',array(
  'template' => 'tour_covers.html',
  'filter' => [
    [
      'filter'=>'TourFilter',
      'match'=>'contains',
      'value'=> $FilterValue,
    ],
    [
      'filter' =>'Title',
      'match'  => 'neq',
      'value'  => '',
    ],
  ],
  'sort' => "Title',
  'sort-order' => 'ASC',
  'count' => 99
  ));

I would like to sort the collection two fields - by Location and then Title.

Many thanks James

James Ng

James Ng 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You can't currently sort my multiple fields. You can create a compound field and sort by that, however.