SPUG: Interesting sort issue
Parr, Ryan
Ryan.Parr at wwireless.com
Tue Oct 23 22:14:18 CDT 2001
For the current implementation of my department's website, I've made a
module (FileAPI) that allows me to utilise pages as data sources easily.
I've also got an SSI CGI script that dynamically builds the drop-down menu
and directory listings according to the directory structure which is
determined using File::Find. The problem I'm running into is that sorting is
very quirky.
The following code:
...
sub preprocess { # File::Find passes the directory listing to
&preprocess if defined
# before doing anything with it, specifically for
sorting or excluding
# directory entries
return sort sorter @_;
}
sub sorter {
my $a_title = lc(FileAPI->new($a)->getTitle());
my $b_title = lc(FileAPI->new($b)->getTitle());
$a_title cmp $b_title;
}
...
does alternating alphabetizing. For instance:
C Directory
A Sub-Directory
B Sub-Directory
C Sub-Directory
B Directory
A Sub-Directory
B Sub-Directory
C Sub-Directory
A Directory
A Sub-Directory
B Sub-Directory
C Sub-Directory
and so on...
I consider this behavior to be bizarre. Any thoughts?
-- Ryan Parr
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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://zipcon.net/spug/
More information about the spug-list
mailing list