Changeset fb6e8e3 for perl


Ignore:
Timestamp:
Feb 23, 2011, 9:25:56 PM (14 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, release-1.8, release-1.9
Children:
7659079
Parents:
259e0475
git-author:
Nelson Elhage <nelhage@mit.edu> (06/17/10 09:41:34)
git-committer:
Nelson Elhage <nelhage@mit.edu> (02/23/11 21:25:56)
Message:
Sort the output of :irc-names
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm

    rc6adf17 rfb6e8e3  
    260260}
    261261
     262sub cmp_user {
     263    my ($lhs, $rhs) = @_;
     264    my ($sigil_l) = ($lhs =~ m{^([+@]?)});
     265    my ($sigil_r) = ($rhs =~ m{^([+@]?)});
     266    my %rank = ('@' => 1, '+' => 2, '' => 3);
     267    return ($rank{$sigil_l} <=> $rank{$sigil_r}) ||
     268            $lhs cmp $rhs;
     269}
     270
    262271sub on_endofnames {
    263272    my ($self, $evt) = @_;
    264273    return unless $self->names_tmp;
    265274    my $names = BarnOwl::Style::boldify("Members of " . [$evt->args]->[1] . ":\n");
    266     for my $name (@{$self->names_tmp}) {
     275    for my $name (sort {cmp_user($a, $b)} @{$self->names_tmp}) {
    267276        $names .= "  $name\n";
    268277    }
Note: See TracChangeset for help on using the changeset viewer.