0 out of 464 challenges solved
Write a Python function `sort_by_second_value` that takes a list of tuples as input and returns a new list where the tuples are sorted in ascending order based on their second value. #### Example Usage ```python [main.nopy] input_data = [('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)] result = sort_by_second_value(input_data) print(result) # Output: [('Social sciences', 82), ('English', 88), ('Science', 90), ('Maths', 97)] ``` #### Constraints - The input list will contain tuples where the second element is always a number. - The function should not modify the original list but return a new sorted list.
def sort_by_second_value(data): """ Sort a list of tuples based on the second value of each tuple. Args: data (list of tuple): A list of tuples to be sorted. Returns: list of tuple: A new list of tuples sorted by the second value. """ # Implement the sorting logic here pass