#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
const int N = 1e4+10;
int x[N], cnt[N]={0}, y[N];
// 原数组 出现次数 排好序的新数组
// 利用出现次数的前缀和排序
// 优化的话考虑最小值和最大值
int main(){
int n ,mxx = -1;
cin>>n;
for(int i = 0 ; i < n; i++) cin>>x[i], cnt[x[i]]++, mxx = max(mxx, x[i]);
for(int i = 1; i <= mxx; i++) cnt[i] += cnt[i-1];
for(int i = 0; i < n; i++) y[cnt[x[i]]--] = x[i];
for(int i = 1; i <= n; i++) cout<<y[i]<<' ';
return 0;
}
10-29
697
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)