sort
Sort an array. If an array of objects is passed, you may optionally pass a key to sort on as the second argument.
Params
array{Array|String}The array to sort.props{String}: One or more properties to sort by.returns{Array}The sorted array.
Usage
{{sort array 'props'}}
Example
You can specify an array item property to sort the array items by.
{{ assign 'products' (sort collection.products 'price') }}
{{#each products as |product|}}
{{ product.title }}
{{/each}}
Was this article helpful to you?