in reply to intermix list of items
That eq definitely does not make sense. I can guess what was in your mind, you probably thought that by using 'eq', sort will group elements for you base on how common they are. No, that is not what sort does. You have to tell sort "between each pair of two elements, how they shall be ordered".
You are looking for something like:
use Data::Dumper; my @list = ('10.1.1.1', '10.1.1.2', '10.2.2.1', '10.2.2.2'); @list = sort intermix @list; print Dumper(@list); sub intermix { return ( substr( $a, 0, rindex($a, '.')) gt substr( $b, 0, rindex($b, '.')) ) ? 1 : 0; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: intermix list of items
by tstock (Curate) on Oct 10, 2004 at 17:20 UTC | |
by pg (Canon) on Oct 10, 2004 at 17:30 UTC |