각 자리별로 정렬 1의자리부터 n의 자리까지
int main() {
int nums[6];
for (int i = 0; i < 6; ++i) scanf("%d", &nums[i]);
int count_a[10] = { 0, };
int count_b[10] = { 0, };
for (int i = 0; i < 6; i++)
{
count_a[nums[i] / 10]++;
count_b[nums[i] % 10]++;
}
int rank_a[10] = { 0, };
int rank_b[10] = { 0, };
rank_a[0] = count_a[0];
rank_b[0] = count_b[0];
for (int i = 1; i < 10; i++)
{
rank_a[i] = rank_a[i - 1] + count_a[i];
rank_b[i] = rank_b[i - 1] + count_b[i];
}
int sorted_arr[6] = { 0, };
for (int i = 5; i >= 0; i--) sorted_arr[--rank_b[nums[i] % 10]] = nums[i];
for (int i = 5; i >= 0; i--) nums[--rank_a[sorted_arr[i] / 10]] = sorted_arr[i];
for (int i = 0; i < 6; ++i) printf("%d ", nums[i]);
return 0;
}