sort modules by dependencies