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

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




> On 01 Jul 2020, at 12:07, Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx> wrote:
> 
> On Wed, 1 Jul 2020 at 20:03, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> 
>> On 7/1/20, Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx> wrote:
>>> Hi,
>>> arr=( -1A -2b -3B 0 1A 2C 3B )
>>> print -rl ${(on)arr}
>>> 
>>> Output:
>>> 0
>>> 1A
>>> -1A
>>> -2b
>>> 2C
>>> 3B
>>> -3B
>>> 
>>> So it's not "correct". How to sort from -3 to 2?
>> 
>> Works fine here,
>> % arr=( -1A -2b -3B 0 1A 2C 3B )
>> % print -rl ${(on)arr}
>> -1A
>> -2b
>> -3B
>> 0
>> 1A
>> 2C
>> 3B

> It's weird  that it's different - could you share `allopt' output?
> 
> And it's not correct - -1 is before -3, etc.

arr=( -1A -2b -3B 0 1A 2C 3B ); print -l ${(on)arr} | sort -h

Or is that cheating?

-- 
ɹןʇnqן
<mailto:lbutler@xxxxxxxxxx>
tel:+1.303.219.0564





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