【发布时间】:2015-10-16 06:33:44
【问题描述】:
我有一个数组列表
ArrayList<String[]> matches = new ArrayList<String[]>();
Collections.sort(matches, new Comparator<String>() {
@Override
public int compare(String word1, String word2) {
return word2.length() - word1.length();
}
});
我想按 ArrayList 中字符串的长度对这个 ArrayList 进行排序。我希望列表按降序排列。
Input = ace, a, apple, cord
Output = apple, cord, ace, a
【问题讨论】:
-
ace, a, apple, cord只是ArrayList<String>,不是ArrayList<String[]>。 -
请说明您迄今为止为解决此问题所采取的步骤。
-
你在哪里尝试解决这个问题?