Just do the actual sort in the MyOrder Package as shown. Note as we pass list references we pass 4 bytes in and 4 bytes out of the MyOrder package.
package MyOrder; my %order = ( ); sub SortCriteria { if ( exists $order{$a} and exists $order{$b} ) { return $order{$a} <=> $order{$b} } elsif ( exists $order{$a} ) { return 1 } elsif ( exists $order{$b} ) { return -1 } else { return $a cmp $b } } sub SortMyWay { my $list_ref = shift; return [sort SortCriteria @$list_ref]; } package main; use strict; my @foo = qw( j a p h , ); my $bar = MyOrder::SortMyWay(\@foo); my @bar = @$bar; print "@bar";
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
In reply to Re: Re: Re: package globals and sort()
by tachyon
in thread package globals and sort()
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |