in reply to Order Pairs
use Text::Soundex 'soundex'; my @words = qw( Cow Phone Speaker Phone Hello World Phon Speaker Clock Phon Torld Hello Hello Worlx ); while( @words ) { push @pairs, [ shift @words, shift @words ]; } @pairs = map { $_->[1] } sort { $a->[0] cmp $b->[0] } map { [ join( '' => sort { $a cmp $b } ( soundex @$_[0], soundex @$_[1] ) ), $_ ] } @pairs; for( @pairs ) { print "@$_\n"; }
output:
Cow Phone Clock Phon Torld Hello Hello World Hello Worlx Speaker Phone Phon Speaker
Update: I've chosen soundex just because it was very easy
to implement.
Other string comparison methods might give better/more exact results.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Order Pairs
by diotalevi (Canon) on Jul 01, 2003 at 16:39 UTC |