Hi hoping for a quick resolution on this as a lot of scripting relies upon it. I have an array:

{% set furniture = [
         'name': 'chair',
         'price': '100'
         'name': 'bench',
         'price': '500'

and I'm trying to sort it by price:

{% set sorted = furniture|multisort(['price'],['SORT_DESC'],['SORT_REGULAR']) %}

but all I get is this error:

array_multisort(): Argument #2 is expected to be an array or a sort flag.

I've also tried:

{% set rides = furniture|multisort(furniture['price'],['SORT_DESC'],['SORT_REGULAR']) %}

but then I get the error:

Key "price" for array with keys "0, 1" does not exist.

I've kind of run out of ideas as to how to tackle it. Thanks.

1 Answer 1


Try removing the quotes on 2nd/3rd arguments:

{% set rides = furniture|multisort(furniture['price'],[SORT_DESC],[SORT_REGULAR]) %}

  • Yes that worked although my syntax was wrong so this worked: {% set sorted = furniture|multisort(['price'],[SORT_ASC],[SORT_REGULAR]) %} Thanks very much for your help!!!!!
    – cannon303
    Jul 17, 2019 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.