import sys

def sorted(lst):
    newlst = list(lst)
    newlst.sort()
    return newlst

def reversed(lst):
    newlst = list(lst)
    return iter(newlst[::-1])

import sys

try:
    sorted = sorted
except NameError:
    def sorted(lst):
        newlst = list(lst)
        newlst.sort()
        return newlst

try:
    reversed = reversed
except NameError:
    def reversed(lst):
        newlst = list(lst)
        return iter(newlst[::-1])

Use builtin sorted, reversed if available.
Use builtin sorted, reversed if available.

  import sys
  
+ try:
+     sorted = sorted
+ except NameError:
- def sorted(lst):
+     def sorted(lst):
-     newlst = list(lst)
+         newlst = list(lst)
-     newlst.sort()
+         newlst.sort()
-     return newlst
+         return newlst
  
+ try:
+     reversed = reversed
+ except NameError:
- def reversed(lst):
+     def reversed(lst):
-     newlst = list(lst)
+         newlst = list(lst)
-     return iter(newlst[::-1])
+         return iter(newlst[::-1])
  
Use builtin sorted, reversed if available.
## Code Before:
import sys

def sorted(lst):
    newlst = list(lst)
    newlst.sort()
    return newlst

def reversed(lst):
    newlst = list(lst)
    return iter(newlst[::-1])

## Instruction:
Use builtin sorted, reversed if available.
## Code After:
import sys

try:
    sorted = sorted
except NameError:
    def sorted(lst):
        newlst = list(lst)
        newlst.sort()
        return newlst

try:
    reversed = reversed
except NameError:
    def reversed(lst):
        newlst = list(lst)
        return iter(newlst[::-1])
