Add tests for sorted() function

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