java里comparator怎么给字符串排序?

2025-03-20 22:07:35
推荐回答(1个)
回答1:

是排序字符串里面的字符吗,先转成数组,

char[]
toCharArray()
Converts this string to a new character array.

再使用 java.util.Arrays 的sort方法
static void sort(T[] a,
Comparator c)
Sorts the specified array of objects according to the order induced by
the specified comparator.