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

Re: Feature request: two level sorting



On 15 June 2016 at 19:12, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> "Feature request: A one-line parameter expansion that converts an
> array to a two-dimensional array by parsing with a pattern match,
> sorts the 2d array on one axis using multiple values of the other
> axis, and then reassembles the original one-dimensional array
> elements again in the new ordering."

Not sure what you mean, I didn't propose such functionality. I went
for a compromise. A shellish or hackish compromise. What can be done
without multi-dimensional arrays in this case? Not much. Except for
providing separate array. A shellish solution. I think such style
gives various opportunities later.

Reading this after hour I see what you mean. You converted two line
"gather array, pass to parameter" to one line "call with pattern
gathering array". Should we do this? It's not shellish. It might
however be Zshish ;) i.e. reasonable, one line, difficult at first
glance. I will keep in mind the call for syntax through the day and
see what I can came up with.

> Can you even suggest a syntax for this that wouldn't look worse than
> the "for" loop you already wrote?

I don't think the for loop is that bad. It's typical imperative code.
One can code in Zsh this way. I had a choice whether to solve
imperatively or via modifying the string in similar manner you later
show, so that "sort string" would equal "sort with grouping". I've
chosen imperative option.

-- 
Best regards,
Sebastian Gniazdowski



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