Sort an array of pairs using Java Arrays.sort() with custom Comparator
Given an array of pairs of integers. The task is to sort the array with respect to the second element of the pair. Examples: Input: [(1, 2), (3, 5), (2, 6), (1, 7)]Output: [(1, 2), (3, 5), (2, 6), (1, 7)] Input: [(10, 20), (20, 30), (5, 6), (2, 5)]Output: [(2, 5), (5, 6), (10, 20), (20, 30)] Approach: Store the pairs in an array using a user-define