Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

1
  • 1
    For zsh the option n does a numeric sort of numbers in a string. It will do a lexicographical sort of the strings prefixing the number, followed by a numeric sort. This is handy for stuff like foo1 foo02 foo3. However, for a pure numeric string, this will fail when negative numbers are in use. a=( 10 8 -20 100 ); echo "${(@n)a}" this returns 8 10 100 -20. Be aware that the sorting of floats is just mimicked. It just does a numeric sort on the fractional part. You can see this with this example a=(1 1.11 1.2); echo ${(n)a} this returns 1 1.2 1.11 because 2 < 11 Commented Feb 5, 2021 at 11:29