in reply to schwartzian transform problem - Solved
Instead of using complex code to make sort efficient, use Sort::Key which handles that for you without the messy code.
use File::Slurper qw( read_text ); use Sort::Key qw( rikeysort ); print rikeysort { ( /(\d+)%/ )[0] } split /^(?=>>> )/m, read_text( 'try3.txt' );
(Also note the more reliable split pattern.)
Features:
Simplicity.
It's a stable sort, meaning it keeps the relative order of already-sorted items.[1]
And it might be the fastest of all provided solutions.
And it's also the fastest of all the provided solutions!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: schwartzian transform problem
by etj (Priest) on Mar 01, 2025 at 10:57 UTC | |
by Cristoforo (Curate) on Mar 21, 2025 at 17:59 UTC | |
by choroba (Cardinal) on Mar 21, 2025 at 19:08 UTC | |
by Cristoforo (Curate) on Mar 22, 2025 at 14:36 UTC | |
by choroba (Cardinal) on Mar 23, 2025 at 11:11 UTC | |
| |
by ikegami (Patriarch) on Mar 25, 2025 at 23:16 UTC |