Solution for sort