"David L. Nicol" wrote:
>
> Hildo Biersma wrote:
> >
> > > =head1 ABSTRACT
> > >
> > > Herein a new syntax is introduced to specify a sort function
> > > for the keys of any hash.
> > >
> > > =head1 DESCRIPTION
> > >
> > > %professors{ $a->name cmp $b->name };
> >
> > I feel the sort order should be specified on the iterator, not on the
> > hash variable. It should be possible to have nexted loops traversing
> > the same hash in different orders.
> >
> > Hildo
>
> What would that look like?
Ah, syntax - I have no idea.
One thing we could do, theoretically:
%hash = ('James' => 'Gibbon',
'Dave' => 'Mallon',
'Pete' => 'Munro');
while (my ($key, $value) = each alphabetic %hash) {
...
}
sub alphabetic (pair $a, pair $b) {
return value $a cmp value $b || key $a cmp key $b;
}
Hildo