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

Re: nesting issue





On 2024-05-04 22:40, Roman Perepelitsa wrote:
local sorted=( $1,*(nN) )

Beautiful.  I get a 'version sort' in one go which is just what I want.  Subsequent to my code snip I run the thing through ' | sort -V ' to get the version sort, but  little 'n' is smart enough to handle that in one line.  Dunno, it always seemed to me that 'numeric sort' is intuitively what the sort command calls 'version sort'. 

This is what I dare say everybody wants:

8 /aWorking/Zsh/Source/Wk/Boneyard 1 % local in=(aaa,*(nN)); print -l $in
aaa,1
aaa,2
aaa,2,howdy
aaa,3a,pard
aaa,3,pard
aaa,4,2a howdy
aaa,5c,pard
aaa,5,pard
aaa,6
aaa,6a,howdy
aaa,7,aaa,7
aaa,8
aaa,9
aaa,9a
aaa,10
aaa,11
aaa,11,pard
aaa,12,12a
aaa,12,some_somme

(
One quibble, I see (cut down):

aaa,3a,pard
aaa,3,pard
aaa,6
aaa,6a,howdy

... I'd expect

aaa,3,pard
aaa,3a,pard

... however ' sort -V' does exactly the same as 'n' so I'm not whining.
)

... and this is not:

8 /aWorking/Zsh/Source/Wk/Boneyard 1 % local in=(aaa,*(nN)); print -l $in | sort -n
aaa,1
aaa,10
aaa,11
aaa,11,pard
aaa,12,12a
aaa,12,some_somme
aaa,2
aaa,2,howdy
aaa,3a,pard
aaa,3,pard
aaa,4,2a howdy
aaa,5c,pard
aaa,5,pard
aaa,6
aaa,6a,howdy
aaa,7,aaa,7
aaa,8
aaa,9
aaa,9a

(sorry about the garbage filenames, they're stress testers.)




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