Adding sorting and print out

Adding functions to assignment code