在Java中排序字符串数组的子集,忽略大小写 [英] Sorting subset of string array in Java, ignoring case
本文介绍了在Java中排序字符串数组的子集,忽略大小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须按字母顺序对CLI参数的子集进行排序.因此,使用以下代码对子集进行排序:
I have to sort subset of CLI arguments alphabetically. So, to sort subset the following code is used:
// Ignore args[0], sort the rest
Arrays.sort(args, 1, args.length);
要忽略大小写,我必须使用某种比较器对象.要使用比较器对子集进行排序,请使用以下方法签名:
And to sort ignoring case, I have to use some sort of comparator object. To sort subset with comparator, there is the following method signature:
Arrays.sort(array, from, to, comp);
是否可以不在单独的行上创建比较器对象而将其包含在Arrays.sort()签名中(即整洁且易于理解)来完成?
Can it be done without creating comparator object on separate line, and include it in the Arrays.sort() signature (i.e. neat and understandable enough)?
推荐答案
您可以使用 查看全文