Sorting related changes

Sorting related changes