Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: How to impose a numeric sort on negative numbers?



On Fri, Jul 3, 2020 at 11:13 AM Lewis Butler <lbutler@xxxxxxxxxx> wrote:
>
> arr=( -1A -2b -3B 0 1A 2C 3B ); print -l ${(on)arr} | sort -h
>
> Or is that cheating?

Well, it's sort of cheating, but it's not correct either, because "1G"
would sort after "1K".  I think you want "sort -n" rather than -h.
And if you're piping to sort anyway, there's no reason to use (on)
first.



Messages sorted by: Reverse Date, Date, Thread, Author