linking sorted for multiple levels