${(O)…}: Sort in descending order

(O) sorts in descending, lexical order. Combined with a, i, n, or - it reverses the sort order of the result.

o is the opposite and sets ascending sort order.

Examples

Lexical, case-sensitive sorting in ascending order
1
2
declare data=(z X A a)
echo "Sorted in descending order: " ${(O)data}
Output:
1
Sorted in descending order:  z X A a
BashSupport Pro is a Zsh IDE with support for ${(O)…}try it now!
© 2020–2024 Joachim Ansorg
Imprint
Privacy Policy
Legal