code: def sort_replies(self, thats=False):
          
          # (Re)initialize the sort cache.
          self._sorted["topics"] = {}
          self._sorted["thats"]  = {}
          self._say("Sorting triggers...")
  
          # Loop through all the topics.
          for topic in self._topics.keys():
              self._say("Analyzing topic " + topic)
  
              # Collect a list of all the triggers we're going to worry about.
              # If this topic inherits another topic, we need to recursively add
              # those to the list as well.
              alltrig = inherit_utils.get_topic_triggers(self, topic, False)
  
              # Sort them.
              self._sorted["topics"][topic] = sorting.sort_trigger_set(alltrig, True, self._say)
  
              # Get all of the %Previous triggers for this topic.
              that_triggers = inherit_utils.get_topic_triggers(self, topic, True)
  
              # And sort them, too.
              self._sorted["thats"][topic] = sorting.sort_trigger_set(that_triggers, False, self._say)
  
          # And sort the substitution lists.
          if not "lists" in self._sorted:
              self._sorted["lists"] = {}
          self._sorted["lists"]["sub"] = sorting.sort_list(self._sub.keys())
          self._sorted["lists"]["person"] = sorting.sort_list(self._person.keys())
docs: Sort the loaded triggers in memory.
  
          After you have finished loading your RiveScript code, call this method
          to populate the various internal sort buffers. This is absolutely
          necessary for reply matching to work efficiently!