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

Re: nesting issue





On 2024-05-05 13:14, Lawrence Velázquez wrote:
Nonsense. There is no universally desired sort. It depends entirely on what the application needs.
Naturally, but I expect that when we are sorting numbers, '2' should come before '10' most of the time.  No not 'everybody' but ... sheesh, I'm just saying that I'm glad that '(n)' gives me what I'd call version sort.  That's all.  Can't I be satisfied?
I don't see this behavior.
...
	aaa,3,pard
	aaa,3a,pard

8 /aWorking/Zsh/Source/Wk/Boneyard 1 % var=( aaa,3*(nN) ); print -l $var       
aaa,3a,pard
aaa,3,pard

... I don't know what to say.

8 /aWorking/Zsh/Source/Wk/Boneyard 1 % var=( aaa,6*(nN) ); print -l $var
aaa,6
aaa,6,    # sixth char ',' precedes sixth char 'a'
aaa,6a
aaa,6a,
aaa,6a,howdy   
# sixth char 'a' precedes sixth char ','
aaa,6,howdy

It's not how I understand sorting but I don't doubt there is some method to it.  'sort' does the same.  'sort' has been around a long time so I don't doubt that what it does is very well thought out whether it makes sense to me or not.   Version sort is not a strict 'dictionary' sort, it 'interprets', so the above does what it thinks best.  I would have expected:

aaa,6,   
aaa,6a
aaa,6,howdy
aaa,6a,howdy

... but that's not the way it is. Not worth worrying about.

vmlinuz-6.1.0-20-amd64

... that's my Linux version, the algorithm for sorting such versions must be a bit arbitrary.  I'm not complaining.







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