题解 | #字符串排序#
字符串排序
http://www.nowcoder.com/practice/5af18ba2eb45443aa91a11e848aa6723
核心代码块:Arrays.sort(arr, String::compareTo);
import java.util.Arrays;
import java.util.Scanner;
/**
* @author
* Created by Administrator on 2022-05-06 03:55
*/
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int num = sc.nextInt();
String[] arr = new String[num + 1];
for (int i = 0; i <= num; i++) {
arr[i] = sc.nextLine();
}
Arrays.sort(arr, String::compareTo);
for (int i = 1; i <= num; i++) {
System.out.println(arr[i]);
}
}
}
}