'Makes sure that dependencies are run before the plugin that
required it'

def order_plugins(self):

    plugin_names = self._plugins_names_dict
    for (plugin_type, enabled_plugins) in plugin_names.iteritems():
        for plugin_name in enabled_plugins:
            plugin_inst = self.get_quick_instance(plugin_type, plugin_name)
            for dep in plugin_inst.get_plugin_deps():
                (dep_plugin_type, dep_name) = dep.split('.')
                if (dep_plugin_type != plugin_type):
                    continue
                try:
                    plugin_index = plugin_names[plugin_type].index(plugin_name)
                    dependency_index = plugin_names[plugin_type].index(dep_name)
                except ValueError:
                    continue
                if (dependency_index < plugin_index):
                    continue
                plugin_names[plugin_type][plugin_index] = dep_name
                plugin_names[plugin_type][dependency_index] = plugin_name
