The example I posted uses concatenation but removes the spaces \040 and thus the problem.
@in = ( ['the cat', 'sat', 'on', 'the', 'mat'], ['the cat sat', 'wherever if felt like'], + ['the cat'], ); my @out = map{$_->[0]} sort{$a->[1] cmp $b->[1]} map{[$_, concat($_ +)]} @in; sub concat { my $ary = shift; $ary = join '', @$ary; $ary =~ s/\s//g; return $ary; } use Data::Dumper; $Data::Dumper::Indent = 0; print map {s/\[/\n \[/g; $_} Dumper \@out; __DATA__ $VAR1 = [ ['the cat'], ['the cat','sat','on','the','mat'], ['the cat sat','wherever if felt like']];
Please explain to me why this is not appropriately sorted and how it is failing? It seemed clear enough to me that he did not want 'the cat' to sort before ('the', 'cat') simply because char 4 of 'the cat' is \040. If I misread the problem and he wants to sort including embeded spaces but not getting a space when you concat with "@ary" then all is required is a local $" = ''; before the sort.
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
In reply to Re: Re: Re: Re: Sort problem
by tachyon
in thread Sort problem
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |