sort modules hierarchically