Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
HTML::AutoPagerize, sort siteinfo by length of url
diff --git a/lib/HTML/AutoPagerize.pm b/lib/HTML/AutoPagerize.pm
index 4282c11..734f329 100644
--- a/lib/HTML/AutoPagerize.pm
+++ b/lib/HTML/AutoPagerize.pm
@@ -19,6 +19,11 @@ sub sites {
$self->{sites};
}
+sub sorted_sites {
+ my $self = shift;
+ return [ sort { length $b->{url} <=> length $a->{url} } @{ $self->sites } ];
+}
+
sub add_site {
my($self, %site) = @_;
@@ -59,7 +64,7 @@ sub handle {
sub site_info_for {
my($self, $uri) = @_;
- for my $site (@{ $self->sites }) {
+ for my $site (@{ $self->sorted_sites }) {
if ($uri =~ $site->{url}) {
return $site;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.