Added Sorting Logic