good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
>
sort { ($a=~/(\d+),/)[0] <=> ($b=~/(\d+),/)[0]
You need that (...)[0] for the match to return the captures in list context, ( <=> is enforcing scalar context and m// only returns captures in list context otherwise boolean ) I'm wondering if there is a prettier solution for that. The Schwartzian transform doesn't have that limitation. ... map { [$_, /(\d+),/] } @list; should do already.
updateclarification: any better solution than (...)[0] to get list context ?
Cheers Rolf In reply to Re^2: How can I sort my array numerically on part of the string? (updated)
by LanX
|
|