in reply to Create sort function from a text file
something like
sub gSort { ($a =~ /B(\d+)/)[0] <=> ($b =~ /B(\d+)/)[0] or ($a =~ /U(\d+)/)[0] <=> ($b =~ /U(\d+)/)[0] }
and later
{ no warnings 'redefine'; do "$path/Sort.cfg.pl"; } my @sorted = sort gSort @data;
untested, since you didn't provide an SSCCE with data
I presumed these are sort configs you coded and not alien input, otherwise I'd surely second haukex' comment about NOT trusting user provided code.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Create sort function from a text file
by Doozer (Scribe) on Aug 16, 2021 at 12:41 UTC | |
by LanX (Saint) on Aug 16, 2021 at 12:48 UTC |