sort { $a =~ y/ //dr cmp $b =~ y/ //dr } @data
####
#!/usr/bin/env perl
use 5.014;
use warnings;
my @test_data = (
[ atcroft => [
'a', #
' b', #
' e', #
' f', #
' g', #
' c', #
' d', #
'h', #
' i', #
' j', #
]],
[ tybalt => [
'j', #
' i', #
' h', #
' g', #
' f', #
' e', #
' d', #
'c', #
' b', #
' a', #
]],
);
say_sorted(@$_) for @test_data;
sub say_sorted {
my ($who, $data) = @_;
say "Data from $who";
say '-' x 20;
say for @$data;
say '-' x 20;
say for sort { $a =~ y/ //dr cmp $b =~ y/ //dr } @$data;
say '=' x 20;
}
####
Data from atcroft
--------------------
a
b
e
f
g
c
d
h
i
j
--------------------
a
b
c
d
e
f
g
h
i
j
====================
Data from tybalt
--------------------
j
i
h
g
f
e
d
c
b
a
--------------------
a
b
c
d
e
f
g
h
i
j
====================