nodes: 0, module; 1, function_definition; 2, function_name:sort_aliases; 3, parameters; 4, block; 5, identifier:self; 6, identifier:aliases; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, expression_statement; 11, return_statement; 12, comment:"""Sorts the given aliases list, returns a sorted list.
  
          :param list aliases:
          :return: sorted aliases list
          """; 13, call; 14, not_operator; 15, block; 16, assignment; 17, list_comprehension; 18, attribute; 19, argument_list; 20, identifier:aliases; 21, return_statement; 22, identifier:parent_aliases; 23, call; 24, identifier:parent_alias; 25, for_in_clause; 26, if_clause; 27, identifier:self; 28, identifier:_cache_init; 29, identifier:aliases; 30, attribute; 31, argument_list; 32, identifier:parent_alias; 33, identifier:parent_aliases; 34, comparison_operator:parent_alias in aliases; 35, call; 36, identifier:keys; 37, identifier:parent_alias; 38, identifier:aliases; 39, attribute; 40, argument_list; 41, identifier:self; 42, identifier:_cache_get_entry; 43, attribute; 44, identifier:self; 45, identifier:CACHE_NAME_PARENTS
code: def sort_aliases(self, aliases):
          """Sorts the given aliases list, returns a sorted list.
  
          :param list aliases:
          :return: sorted aliases list
          """
          self._cache_init()
          if not aliases:
              return aliases
          parent_aliases = self._cache_get_entry(self.CACHE_NAME_PARENTS).keys()
          return [parent_alias for parent_alias in parent_aliases if parent_alias in aliases]