TDD5

add sorting logic and give the correct sorted order