nodes: 0, module; 1, function_definition; 2, function_name:_sorted_keys; 3, parameters; 4, block; 5, identifier:self; 6, identifier:keys; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, for_statement; 11, for_statement; 12, if_statement; 13, return_statement; 14, comment:"""Sort keys, dropping the ones that should be ignored.
  
          The keys that are in ``self.ignored_keys`` or that end on
          '_best' are dropped. Among the remaining keys:
            * 'epoch' is put first;
            * 'dur' is put last;
            * keys that start with 'event_' are put just before 'dur';
            * all remaining keys are sorted alphabetically.
          """; 15, assignment; 16, boolean_operator; 17, block; 18, identifier:key; 19, call; 20, block; 21, identifier:key; 22, call; 23, block; 24, boolean_operator; 25, block; 26, identifier:sorted_keys; 27, identifier:sorted_keys; 28, list; 29, parenthesized_expression; 30, parenthesized_expression; 31, expression_statement; 32, identifier:sorted; 33, argument_list; 34, if_statement; 35, identifier:sorted; 36, argument_list; 37, if_statement; 38, parenthesized_expression; 39, parenthesized_expression; 40, expression_statement; 41, comparison_operator:'epoch' in keys; 42, comparison_operator:'epoch' not in self.keys_ignored_; 43, call; 44, identifier:keys; 45, not_operator; 46, block; 47, identifier:keys; 48, boolean_operator; 49, block; 50, comparison_operator:'dur' in keys; 51, comparison_operator:'dur' not in self.keys_ignored_; 52, call; 53, string; 54, identifier:keys; 55, string; 56, attribute; 57, attribute; 58, argument_list; 59, parenthesized_expression; 60, expression_statement; 61, call; 62, parenthesized_expression; 63, expression_statement; 64, string; 65, identifier:keys; 66, string; 67, attribute; 68, attribute; 69, argument_list; 70, string_content:epoch; 71, string_content:epoch; 72, identifier:self; 73, identifier:keys_ignored_; 74, identifier:sorted_keys; 75, identifier:append; 76, string; 77, boolean_operator; 78, call; 79, attribute; 80, argument_list; 81, comparison_operator:key not in self.keys_ignored_; 82, call; 83, string_content:dur; 84, string_content:dur; 85, identifier:self; 86, identifier:keys_ignored_; 87, identifier:sorted_keys; 88, identifier:append; 89, string; 90, string_content:epoch; 91, boolean_operator; 92, call; 93, attribute; 94, argument_list; 95, identifier:key; 96, identifier:startswith; 97, string; 98, identifier:key; 99, attribute; 100, attribute; 101, argument_list; 102, string_content:dur; 103, boolean_operator; 104, call; 105, attribute; 106, argument_list; 107, identifier:sorted_keys; 108, identifier:append; 109, identifier:key; 110, string_content:event_; 111, identifier:self; 112, identifier:keys_ignored_; 113, identifier:sorted_keys; 114, identifier:append; 115, identifier:key; 116, parenthesized_expression; 117, parenthesized_expression; 118, attribute; 119, argument_list; 120, identifier:key; 121, identifier:startswith; 122, string; 123, comparison_operator:key in ('epoch', 'dur'); 124, comparison_operator:key in self.keys_ignored_; 125, identifier:key; 126, identifier:endswith; 127, string; 128, string_content:event_; 129, identifier:key; 130, tuple; 131, identifier:key; 132, attribute; 133, string_content:_best; 134, string; 135, string; 136, identifier:self; 137, identifier:keys_ignored_; 138, string_content:epoch; 139, string_content:dur
code: def _sorted_keys(self, keys):
          """Sort keys, dropping the ones that should be ignored.
  
          The keys that are in ``self.ignored_keys`` or that end on
          '_best' are dropped. Among the remaining keys:
            * 'epoch' is put first;
            * 'dur' is put last;
            * keys that start with 'event_' are put just before 'dur';
            * all remaining keys are sorted alphabetically.
          """
          sorted_keys = []
          if ('epoch' in keys) and ('epoch' not in self.keys_ignored_):
              sorted_keys.append('epoch')
  
          for key in sorted(keys):
              if not (
                      (key in ('epoch', 'dur')) or
                      (key in self.keys_ignored_) or
                      key.endswith('_best') or
                      key.startswith('event_')
              ):
                  sorted_keys.append(key)
  
          for key in sorted(keys):
              if key.startswith('event_') and (key not in self.keys_ignored_):
                  sorted_keys.append(key)
          if ('dur' in keys) and ('dur' not in self.keys_ignored_):
              sorted_keys.append('dur')
          return sorted_keys