N개의 수가 주어졌을 때, 이를 오름차순으로 정렬하는 프로그램을 작성하시오.
import java.io.*;
import java.util.*;
class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));
int n=Integer.parseInt(br.readLine());
int[] counting=new int[20000001];
int[] array=new int[n];
int[] sorted=new int[n];
for(int i=0; i<n; i++)
array[i]=Integer.parseInt(br.readLine());
for(int i=0; i<n; i++)
counting[array[i]]++;
for(int i=0;i<20000000;i++)
counting[i+1]+=counting[i];
for(int i=n-1; i>=0; i--)
sorted[--counting[array[i]]]=array[i];
for(int i:sorted)
bw.write(i+"\n");
bw.flush();
}
}