Sort an array by key as parameter 1 and direction (asc
/desc
) as parameter 2. If sorting a primitive list no parameters are necessary.
primitive: - Zebra - Alpha - Bravocomplex: - last_name: Zebra first_name: Zealous - last_name: Alpha first_name: Altruistic - last_name: Bravo first_name: Blathering
{{ primitive | sort | list }} {{ complex | sort('last_name') }} Hello, {{ first_name }} {{ last_name }}{{ /complex }} {{ complex | sort('last_name', 'desc') }} Hello, {{ first_name }} {{ last_name }}{{ /complex }}
Alpha, Bravo, Zebra Hello, Altruistic AlphaHello, Blathering BravoHello, Zealous Zebra Hello, Zealous ZebraHello, Blathering BravoHello, Altruistic Alpha