如何按每个字符串数组的索引按字母顺序对字符串数组的数组列表进行排序?

问题描述 投票:0回答:0

我有这个数组:

ArrayList<String[]> passes = new ArrayList<>();

我想按每个数组的索引对这个数组进行排序。

例如,如果 ArrayList 看起来像这样:

{banana, cherry}
{apple, donut}
{apple, carrot}

排序看起来像:

{apple, carrot}
{apple, donut}
{banana, cherry}

因为字母表中 a 在 b 之前,在香蕉数组上方有两个苹果数组。然后胡萝卜数组越过甜甜圈数组,因为 c 在 d 之前。

java sorting arraylist alphabetical
© www.soinside.com 2019 - 2024. All rights reserved.