Flex implementation in sorting