nodes: 0, module; 1, function_definition; 2, function_name:sort_dependencies; 3, parameters; 4, block; 5, identifier:self; 6, identifier:image; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, if_statement; 11, expression_statement; 12, for_statement; 13, expression_statement; 14, return_statement; 15, identifier:dependencies; 16, None; 17, comment:"""
          Topologically sort the docker commands by their requirements
  
          Note:
              Circular "requires" dependencies are assumed to have already been checked in
              get_external_base_image, they are not checked here
  
          Args:
             image (str): process this docker image's dependencies
             dependencies (OrderedDict): running cache of sorted dependencies (ordered dict)
  
          Returns:
              List[str]: list of dependencies a topologically-sorted build order
          """; 18, comparison_operator:dependencies is None; 19, block; 20, comparison_operator:image in dependencies; 21, block; 22, assignment; 23, identifier:dep; 24, identifier:requires; 25, block; 26, assignment; 27, call; 28, identifier:dependencies; 29, None; 30, expression_statement; 31, comment:# using this as an ordered set - not storing any values; 32, identifier:image; 33, identifier:dependencies; 34, return_statement; 35, identifier:requires; 36, call; 37, expression_statement; 38, subscript; 39, None; 40, attribute; 41, argument_list; 42, assignment; 43, attribute; 44, argument_list; 45, call; 46, identifier:dependencies; 47, identifier:image; 48, identifier:dependencies; 49, identifier:keys; 50, identifier:dependencies; 51, call; 52, subscript; 53, identifier:get; 54, string; 55, list; 56, attribute; 57, argument_list; 58, identifier:OrderedDict; 59, argument_list; 60, attribute; 61, identifier:image; 62, string_content:requires; 63, identifier:self; 64, identifier:sort_dependencies; 65, identifier:dep; 66, identifier:dependencies; 67, identifier:self; 68, identifier:ymldefs
code: def sort_dependencies(self, image, dependencies=None):
          """
          Topologically sort the docker commands by their requirements
  
          Note:
              Circular "requires" dependencies are assumed to have already been checked in
              get_external_base_image, they are not checked here
  
          Args:
             image (str): process this docker image's dependencies
             dependencies (OrderedDict): running cache of sorted dependencies (ordered dict)
  
          Returns:
              List[str]: list of dependencies a topologically-sorted build order
          """
          if dependencies is None:
              dependencies = OrderedDict()  # using this as an ordered set - not storing any values
  
          if image in dependencies:
              return
  
          requires = self.ymldefs[image].get('requires', [])
  
          for dep in requires:
              self.sort_dependencies(dep, dependencies)
  
          dependencies[image] = None
          return dependencies.keys()