本文介绍了排序字符串数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Java中有一个字符串数组。我需要根据单词中的字符a的数量(降序)对其进行排序。如果某些单词包含相同数量的字符a,那么我需要按照它们的长度(递减顺序)对这些单词进行排序。如果长度相同,则按字母顺序排列。
示例数组:
I have a string array in Java. I need to sort it by the number of character "a"s within the word (decreasing order). If some words contain same number of character a, then I need to sort those words by their lengths(decreasing order). And if the length is same, then alphabetically.
Example array:
["aaaasd","a","aab","aaaabcd","ef","cssssssd","fdz","kf","zc","lklklklklklk","l"]
需要排序如下:
needs to be sorted like:
["aaaabcd","aaaasd","aab","a","lklklklklklk","cssssssd","fdz","ef","kf","zc","l"]
我尝试过:
我不知道如何制作。你能帮忙吗?
提前致谢
What I have tried:
I don't have any idea how to make. Could you help?
Thanks in advance
推荐答案
这篇关于排序字符串数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!