We don't bite newbies here... much | |
PerlMonks |
Re^3: How to perform different sorts on multiple sections of items in the same arrayby johngg (Canon) |
on Dec 30, 2014 at 12:28 UTC ( [id://1111710]=note: print w/replies, xml ) | Need Help?? |
Perhaps I misinterpreted the OP's spec. I thought the requirement was to sort all those containing an 'r' followed by those starting with an 'e' and finally the remainder but I can see that your interpretation of leaving each set in their relative positions could be more accurate. Perhaps estreb could clarify?
I'm not sure you are correct in those statements. The if ( m{r} ) { ... } elsif ( m{^e} ) { ... } else { ... } section assigns ascending values to $type which is packed as the first term and becomes the primary key for the sort. Thus all those starting with an 'r' are sorted separately from those starting with 'e' which are again separate from the remainder. I think this is demonstrated by the output.
Please let me know if you still think I am having a senior moment and have got this aspect of the algorithm completely wrong. Update: Corrected wrong variable in explanation, s/$ord/$type/ Cheers, JohnGG
In Section
Seekers of Perl Wisdom
|
|