题解 | #字符串排序#
字符串排序
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)); } }