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

Re: Feature request: two level sorting



On Jun 16,  1:02am, Mikael Magnusson wrote:
}
} Well, this old trick always works if you don't mind depending on /
} being readable, but that's probably a safe assumption usually.
} 
} % myarray=("aaa-A" "aab-B" "aac-A" "aad-C")
} % echo /(e:'reply=($myarray)':oe:'REPLY=${REPLY#*-}':)
} aac-A aaa-A aab-B aad-C

Heh, you don't even need / to be readable, any single readable file
will do:

torch% echo /dev/null(e:'reply=($myarray)':oe:'REPLY=${REPLY#*-}':)
aac-A aaa-A aab-B aad-C

Rather hard to embed that in a parameter expansion context without
using a process substitution, though.  And I don't think it covers
the secondary sort: note that in Sebastian's original example he
wants (aaa-A aac-A) but the above output has them the other way
(the sort isn't guaranteed to be stable).



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