<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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]))