Adds the module and its dependencies to the result list in dependency order.

def _process_module_needs(self, modules):
        """Adds the module and its dependencies to the result list in dependency order."""
        result = list(modules)
        for i, module in enumerate(modules):
            #It is possible that the parser couldn't find it, if so
            #we can't create the executable!
            if module in self.module.parent.modules:
                modneeds = self.module.parent.modules[module].needs
                for modn in modneeds:
                    if modn not in result:
                        #Since this module depends on the other, insert the other
                        #above it in the list.
                        result.insert(i, modn)
                    else:
                        x = result.index(modn)
                        if x > i:
                            #We need to move this module higher up in the food chain
                            #because it is needed sooner.
                            result.remove(modn)
                            result.insert(i, modn)

                    newi = result.index(modn)
            else:
                raise ValueError("Unable to find module {}.".format(module))

        return result