# Compare two elements using either standard lexical comparison or the sortsub # provided to the object's constructor. sub _compare { my ( $self, $item_a, $item_b ) = @_; my $sortsub = $self->_get_sortsub; if ( defined $sortsub ) { local $a = $item_a; local $b = $item_b; return $sortsub->( $a, $b ); } else { return $item_a cmp $item_b; } }