def extend_replace_worst(self, rules, specializations):
        '''
        Extends the list by replacing the worst rules.
        '''
        def is_similar(new_rule):
            for rule in rules[:]:
                if rule.similarity(new_rule) == 1:
                    return True
            return False

        improved = False
        for new_rule in sorted(specializations, key=lambda rule: rule.score):
            worst = sorted(rules, key=lambda rule: rule.score)[0]
            if self.n < len(rules):
                rules.append(new_rule)
                improved = True
            elif new_rule.score > worst.score and not is_similar(new_rule):
                self._replace(rules, worst, new_rule)
                improved = True
        return improved
dataset/ETHPy150Open anzev/hedwig/hedwig/learners/learner.py/Learner.extend_replace_worst/swapped operands of `<`