Write a function to sort the given list of tuples in Python according to the second element of the tuple.
tuple_list = [(1, 10), (2, 7), (3, 5), (4, 8)]
def sort_by_second_elem(tuple_list):
    return sorted(tuple_list, key=lambda x: x[1])