First version of mutual definitions sorting