Add test for sort used in chain