4. (15分) We have a set of n open intervals \( S = \{(ai, bi): i = 1, \dots, n\} \). We want to choose a largest subset \( S' \subseteq S \) such that the selected intervals in \( S' \) are mutually disjoint. Please give an O(nlog n)-time algorithm to solve this problem.