Add sort functionality along with JUnit test for the same