题解 | #字符串排序#

字符串排序

https://www.nowcoder.com/practice/5af18ba2eb45443aa91a11e848aa6723

import java.util.*;


public class Main {
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        int count = Integer.parseInt(sc.nextLine());
        if(count > 1000 || count < 1) {
            return;
        }
        List<String> list = new ArrayList<>(count);
        while(count-- > 0){
            String str = sc.nextLine();
            list.add(str);
        }
        list.sort((o1, o2) -> o1.toUpperCase().compareTo(o2.toUpperCase()));
        list.forEach(value -> System.out.println(value));
    }
}

全部评论

相关推荐

WhiteAlbum...:学院本2中大厂垂直实习➕acm比赛 秋招0面试
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务