nodes: 0, module; 1, function_definition; 2, function_name:sort_by_tag; 3, parameters; 4, block; 5, identifier:self; 6, identifier:tag; 7, expression_statement; 8, return_statement; 9, comment:"""Sorts the `AmpalContainer` by a tag on the component objects.
  
          Parameters
          ----------
          tag : str
              Key of tag used for sorting.
          """; 10, call; 11, identifier:AmpalContainer; 12, argument_list; 13, call; 14, identifier:sorted; 15, argument_list; 16, identifier:self; 17, keyword_argument; 18, identifier:key; 19, lambda; 20, lambda_parameters; 21, subscript; 22, identifier:x; 23, attribute; 24, identifier:tag; 25, identifier:x; 26, identifier:tags
code: def sort_by_tag(self, tag):
          """Sorts the `AmpalContainer` by a tag on the component objects.
  
          Parameters
          ----------
          tag : str
              Key of tag used for sorting.
          """
          return AmpalContainer(sorted(self, key=lambda x: x.tags[tag]))