nodes: 0, module; 1, function_definition; 2, function_name:sort_replies; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, expression_statement; 8, comment:# (Re)initialize the sort cache.; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, comment:# Loop through all the topics.; 13, for_statement; 14, comment:# And sort the substitution lists.; 15, if_statement; 16, expression_statement; 17, expression_statement; 18, identifier:thats; 19, False; 20, comment:"""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!
          """; 21, assignment; 22, assignment; 23, call; 24, identifier:topic; 25, call; 26, block; 27, not_operator; 28, block; 29, assignment; 30, assignment; 31, subscript; 32, dictionary; 33, subscript; 34, dictionary; 35, attribute; 36, argument_list; 37, attribute; 38, argument_list; 39, expression_statement; 40, comment:# Collect a list of all the triggers we're going to worry about.; 41, comment:# If this topic inherits another topic, we need to recursively add; 42, comment:# those to the list as well.; 43, expression_statement; 44, comment:# Sort them.; 45, expression_statement; 46, comment:# Get all of the %Previous triggers for this topic.; 47, expression_statement; 48, comment:# And sort them, too.; 49, expression_statement; 50, comparison_operator:"lists" in self._sorted; 51, expression_statement; 52, subscript; 53, call; 54, subscript; 55, call; 56, attribute; 57, string:"topics"; 58, attribute; 59, string:"thats"; 60, identifier:self; 61, identifier:_say; 62, string:"Sorting triggers..."; 63, attribute; 64, identifier:keys; 65, call; 66, assignment; 67, assignment; 68, assignment; 69, assignment; 70, string:"lists"; 71, attribute; 72, assignment; 73, subscript; 74, string:"sub"; 75, attribute; 76, argument_list; 77, subscript; 78, string:"person"; 79, attribute; 80, argument_list; 81, identifier:self; 82, identifier:_sorted; 83, identifier:self; 84, identifier:_sorted; 85, identifier:self; 86, identifier:_topics; 87, attribute; 88, argument_list; 89, identifier:alltrig; 90, call; 91, subscript; 92, call; 93, identifier:that_triggers; 94, call; 95, subscript; 96, call; 97, identifier:self; 98, identifier:_sorted; 99, subscript; 100, dictionary; 101, attribute; 102, string:"lists"; 103, identifier:sorting; 104, identifier:sort_list; 105, call; 106, attribute; 107, string:"lists"; 108, identifier:sorting; 109, identifier:sort_list; 110, call; 111, identifier:self; 112, identifier:_say; 113, binary_operator:"Analyzing topic " + topic; 114, attribute; 115, argument_list; 116, subscript; 117, identifier:topic; 118, attribute; 119, argument_list; 120, attribute; 121, argument_list; 122, subscript; 123, identifier:topic; 124, attribute; 125, argument_list; 126, attribute; 127, string:"lists"; 128, identifier:self; 129, identifier:_sorted; 130, attribute; 131, argument_list; 132, identifier:self; 133, identifier:_sorted; 134, attribute; 135, argument_list; 136, string:"Analyzing topic "; 137, identifier:topic; 138, identifier:inherit_utils; 139, identifier:get_topic_triggers; 140, identifier:self; 141, identifier:topic; 142, False; 143, attribute; 144, string:"topics"; 145, identifier:sorting; 146, identifier:sort_trigger_set; 147, identifier:alltrig; 148, True; 149, attribute; 150, identifier:inherit_utils; 151, identifier:get_topic_triggers; 152, identifier:self; 153, identifier:topic; 154, True; 155, attribute; 156, string:"thats"; 157, identifier:sorting; 158, identifier:sort_trigger_set; 159, identifier:that_triggers; 160, False; 161, attribute; 162, identifier:self; 163, identifier:_sorted; 164, attribute; 165, identifier:keys; 166, attribute; 167, identifier:keys; 168, identifier:self; 169, identifier:_sorted; 170, identifier:self; 171, identifier:_say; 172, identifier:self; 173, identifier:_sorted; 174, identifier:self; 175, identifier:_say; 176, identifier:self; 177, identifier:_sub; 178, identifier:self; 179, identifier:_person
code: def sort_replies(self, thats=False):
          """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!
          """
          # (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())