first sort and then it would be easy