def instances_get(opts, plugins, url_file_input, out):
    instances = OrderedDict()
    preferred_order = ['wordpress', 'joomla', 'drupal']
    for cms_name in preferred_order:
        for plugin in plugins:
            plugin_name = plugin.__name__.lower()
            if cms_name == plugin_name:
                instances[plugin_name] = instance_get(plugin, opts,
                        url_file_input, out)
    for plugin in plugins:
        plugin_name = plugin.__name__.lower()
        if plugin_name not in preferred_order:
            instances[plugin_name] = instance_get(plugin, opts,
                    url_file_input, out)
    return instances