# Import the NumPy library
import numpy as np
arr = np.array([[3, 5, 2], [1, 4, 6], [8, 2, 9]])
n = 1

# Sort the array using np.lexsort
sorted_arr = arr[np.lexsort((arr[:, n], ))]

print(sorted_arr)