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

def order_components_for_import(self, repository_ids, repo_info_dicts):

    ordered_repository_ids = []
    ordered_repositories = []
    ordered_changeset_revisions = []
    prior_import_required_dict = repository_util.get_prior_import_or_install_required_dict(self.app, repository_ids, repo_info_dicts)
    processed_repository_ids = []
    while (len(processed_repository_ids) != len(prior_import_required_dict.keys())):
        repository_id = suc.get_next_prior_import_or_install_required_dict_entry(prior_import_required_dict, processed_repository_ids)
        if (repository_id == self.repository_id):
            processed_repository_ids.append(self.repository_id)
            continue
        processed_repository_ids.append(repository_id)
        if (repository_id not in ordered_repository_ids):
            prior_import_required_ids = prior_import_required_dict[repository_id]
            for prior_import_required_id in prior_import_required_ids:
                if (prior_import_required_id not in ordered_repository_ids):
                    prior_repo_info_dict = self.get_repo_info_dict_for_import(prior_import_required_id, repository_ids, repo_info_dicts)
                    (prior_repository, prior_import_changeset_revision) = self.get_components_from_repo_info_dict(prior_repo_info_dict)
                    if (prior_repository and prior_import_changeset_revision):
                        ordered_repository_ids.append(prior_import_required_id)
                        ordered_repositories.append(prior_repository)
                        ordered_changeset_revisions.append(prior_import_changeset_revision)
            repo_info_dict = self.get_repo_info_dict_for_import(repository_id, repository_ids, repo_info_dicts)
            (repository, changeset_revision) = self.get_components_from_repo_info_dict(repo_info_dict)
            if (repository and changeset_revision):
                ordered_repository_ids.append(repository_id)
                ordered_repositories.append(repository)
                ordered_changeset_revisions.append(changeset_revision)
    repo_info_dict = self.get_repo_info_dict_for_import(self.repository_id, repository_ids, repo_info_dicts)
    (repository, changeset_revision) = self.get_components_from_repo_info_dict(repo_info_dict)
    if (repository and changeset_revision):
        ordered_repository_ids.append(repository_id)
        ordered_repositories.append(repository)
        ordered_changeset_revisions.append(changeset_revision)
    return (ordered_repository_ids, ordered_repositories, ordered_changeset_revisions)
