add sorting test cases
add sorting logic