'Some repositories may have repository dependencies that are required to be installed
before the dependent repository.  This method will inspect the list of repositories
about to be installed and make sure to order them appropriately.  For each repository
about to be installed, if required repositories are not contained in the list of repositories
about to be installed, then they are not considered.  Repository dependency definitions
that contain circular dependencies should not result in an infinite loop, but obviously
prior installation will not be handled for one or more of the repositories that require
prior installation.'

def order_components_for_installation(self, tsr_ids, repo_info_dicts, tool_panel_section_keys):

    ordered_tsr_ids = []
    ordered_repo_info_dicts = []
    ordered_tool_panel_section_keys = []
    prior_install_required_dict = repository_util.get_prior_import_or_install_required_dict(self.app, tsr_ids, repo_info_dicts)
    processed_tsr_ids = []
    while (len(processed_tsr_ids) != len(prior_install_required_dict.keys())):
        tsr_id = suc.get_next_prior_import_or_install_required_dict_entry(prior_install_required_dict, processed_tsr_ids)
        processed_tsr_ids.append(tsr_id)
        if (tsr_id not in ordered_tsr_ids):
            prior_install_required_ids = prior_install_required_dict[tsr_id]
            for prior_install_required_id in prior_install_required_ids:
                if (prior_install_required_id not in ordered_tsr_ids):
                    (prior_repo_info_dict, prior_tool_panel_section_key) = self.get_repository_components_for_installation(prior_install_required_id, tsr_ids, repo_info_dicts, tool_panel_section_keys=tool_panel_section_keys)
                    ordered_tsr_ids.append(prior_install_required_id)
                    ordered_repo_info_dicts.append(prior_repo_info_dict)
                    ordered_tool_panel_section_keys.append(prior_tool_panel_section_key)
            (repo_info_dict, tool_panel_section_key) = self.get_repository_components_for_installation(tsr_id, tsr_ids, repo_info_dicts, tool_panel_section_keys=tool_panel_section_keys)
            if (tsr_id not in ordered_tsr_ids):
                ordered_tsr_ids.append(tsr_id)
                ordered_repo_info_dicts.append(repo_info_dict)
                ordered_tool_panel_section_keys.append(tool_panel_section_key)
    return (ordered_tsr_ids, ordered_repo_info_dicts, ordered_tool_panel_section_keys)
