${(o)…}: Sort in ascending order

(o) sorts in ascending order. It’s the default sort order of flags a, i, n, and -.

O is the opposite and sets descending sort order.

Examples

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