def sort(self):
<EOL>for priority, triggers in self._triggers.items():<EOL><INDENT>self._log.debug('<STR_LIT>'.format(priority=priority))<EOL>atomics = [trigger for trigger in triggers if trigger.pattern_is_atomic]<EOL>wildcards = [trigger for trigger in triggers if not trigger.pattern_is_atomic]<EOL>atomics = sorted(atomics, key=lambda trigger: (trigger.pattern_words, trigger.pattern_len), reverse=True)<EOL>wildcards = sorted(wildcards, key=lambda trigger: (trigger.pattern_words, trigger.pattern_len),<EOL>reverse=True)<EOL>self._triggers[priority] = atomics + wildcards<EOL><DEDENT>self._sorted_triggers = []<EOL>for triggers in [self._triggers[priority] for priority in sorted(self._triggers.keys(), reverse=True)]:<EOL><INDENT>for trigger in triggers:<EOL><INDENT>self._sorted_triggers.append(trigger)<EOL><DEDENT><DEDENT>self.sorted = True<EOL>
Sort triggers and their associated responses