in reply to Re: Re: How to sort hash tables alpha-numeric
in thread How to sort hash tables alpha-numeric
A modified version of the sorted routine which also takes the leading letters into account:
The split function is replaced by a regex which returns a list of letters and the numbers.sub sorted { return map { $_->[0] } sort { $a->[1] cmp $b->[1] || $a->[2] <=> $b->[2] || $a->[3] <=> $b->[3] } map { [ $_, (/([A-Z]+)(\d+)(?:-(\d+)){1,2}/) ] } @_; }
Arjen
|
---|