in reply to Sorting numerials first and then numerials with alpha characters last
#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11138205 use warnings; open my $fh, '<', \<<END or die; <t id=2bc>Only the...</t> <t id=1>Only the...</t> <t id=12>Only the...</t> <t id=21>Only the...</t> <t id=1>Only the...</t> <t id=1a>Only the...</t> <t id=2>Only the...</t> <t id=2>Only the...</t> <t id=2>Only the...</t> <t id=2>Only the...</t> <t id=3>Only the...</t> <t id=35>Only the...</t> <t id=31>Only the...</t> <t id=2b>Only the...</t> <t id=4>Only the...</t> <t id=42>Only the...</t> <t id=5>Only the...</t> <t id=51>Only the...</t> <t id=2ac>Only the...</t> <t id=52>Only the...</t> <t id=6>Only the...</t> <t id=7>Only the...</t> END print sort { my ($anum, $achars, $bnum, $bchars) = map /<t id=(\d+)(\w*)>/, $a, $ +b; $achars cmp $bchars || $anum <=> $bnum } <$fh>;
|
|---|