Worked on sorting functionality