Add tests for sorted() function

and check that sorted(list) produces same output as list.sort()