SPUG: Packed Default Sort

Richard Anderson starfire at zipcon.net
Wed Sep 20 20:49:44 CDT 2000


On Wednesday, September 20, 2000 3:23 PM, Yitzchak Scott-Thoennes"
<sthoenna at efn.org> wrote:

Subject: Re: SPUG: Packed Default Sort
>
> And from 5.7.0:
>
> =head1 Performance Enhancements
>
> and that sort() is now stable (meaning that elements with identical
> keys will stay ordered as they were before the sort).

This explains the arbitrary switching of the order of at_large and atlarge
in this example (dictionary order sort, run with perl 5.005_02):

use locale;   # Enable use of POSIX locales for defining sort order
@array = qw(ASCII ascap at_large atlarge A ARP arp);
@dictionary_sorted = sort {
                             my $da = lc $a;
                             my $db = lc $b;
                             $da =~ s/[\W_]+//g;
                             $db =~ s/[\W_]+//g;
                             $da cmp $db;
                          } @array;
print "@dictionary_sorted\n";
A ARP arp ascap ASCII atlarge at_large

Richard.Anderson at raycosoft.com
www.zipcon.net/~starfire/home (personal)
www.raycosoft.com (corporate)



 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/





More information about the spug-list mailing list