modification median sort