nodes: 0, module; 1, function_definition; 2, function_name:sort_by; 3, parameters; 4, block; 5, identifier:self; 6, list_splat_pattern; 7, expression_statement; 8, comment:# Support sorting by file_ids or keys.; 9, expression_statement; 10, comment:# self.record['_files'] = [{'key': files.get(id_, id_)} for id_ in ids]; 11, expression_statement; 12, expression_statement; 13, identifier:ids; 14, comment:"""Update files order.
  
          :param ids: List of ids specifying the final status of the list.
          """; 15, assignment; 16, assignment; 17, call; 18, identifier:files; 19, dictionary_comprehension; 20, attribute; 21, call; 22, attribute; 23, argument_list; 24, pair; 25, for_in_clause; 26, identifier:self; 27, identifier:filesmap; 28, identifier:OrderedDict; 29, argument_list; 30, identifier:self; 31, identifier:flush; 32, call; 33, attribute; 34, identifier:f_; 35, identifier:self; 36, list_comprehension; 37, identifier:str; 38, argument_list; 39, identifier:f_; 40, identifier:key; 41, tuple; 42, for_in_clause; 43, attribute; 44, call; 45, call; 46, identifier:id_; 47, identifier:ids; 48, identifier:f_; 49, identifier:file_id; 50, attribute; 51, argument_list; 52, attribute; 53, argument_list; 54, identifier:files; 55, identifier:get; 56, identifier:id_; 57, identifier:id_; 58, subscript; 59, identifier:dumps; 60, identifier:self; 61, call; 62, attribute; 63, argument_list; 64, identifier:files; 65, identifier:get; 66, identifier:id_; 67, identifier:id_
code: def sort_by(self, *ids):
          """Update files order.
  
          :param ids: List of ids specifying the final status of the list.
          """
          # Support sorting by file_ids or keys.
          files = {str(f_.file_id): f_.key for f_ in self}
          # self.record['_files'] = [{'key': files.get(id_, id_)} for id_ in ids]
          self.filesmap = OrderedDict([
              (files.get(id_, id_), self[files.get(id_, id_)].dumps())
              for id_ in ids
          ])
          self.flush()