<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def instances_get(opts, plugins, url_file_input, out):
 """ Creates and returns an ordered dictionary containing instances for all available scanning plugins, sort of ordered by popularity. @param opts: options as returned by self._options. @param plugins: plugins as returned by plugins_util.plugins_base_get. @param url_file_input: boolean value which indicates whether we are scanning an individual URL or a file. This is used to determine kwargs required. @param out: self.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