This and other RFCs are available on the web at http://dev.perl.org/rfc/ =head1 TITLE Sort order for any hash =head1 VERSION Maintainer: David Nicol <[EMAIL PROTECTED]> Date: 17 Aug 2000 Version: 1 Mailing List: [EMAIL PROTECTED] Number: 124 =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 }; %students{ $$students{$b}{GPA} <=> $$students{$a}{GPA} }; is proposed as an extension to specify a "sort order" on the values returned from the each, keys, and values functions regarding the associative array. When the assignment is made, the expression returns the an anonymous coderef which can be saved and restored to the hash later if needed. The expression can also be made temporary by use of the C<my> or C<local> operators. The side effects of making a large, tied array a sorted large tied array are possibly dangerous. =head1 IMPLEMENTATION A "sort function" will need to be added into the list of magics maintained for every associative array. A set of macros in terms of sort will need to be defined which replace keys, values, and each functions on sorted arrays Since the proposed syntax is currently an error, little modification to the parser will be required: Fatal syntax errors may be filtered for this instance. =head1 REFERENCES http://www.mail-archive.com/[email protected]/msg01950.html
