#include <stdio.h>
void CountSort(int *arr, int len, int *temp) {
int i, j;
int count[len];
for (i = 0; i < len; i++)
count[i] = 0;
for (i = 0; i < len - 1; i++) {
for (j = i + 1; j < len; j++) {
if (arr[i] > arr[j]) {
count[i]++;
} else {
count[j]++;
}
}
}
for (i = 0; i < len; i++) {
temp[count[i]] = arr[i];
}
}
void display(int *arr, int len) {
for (int i = 0; i < len; i++)
printf("%d ", arr[i]);
}
int main() {
int arr[] = {15, 7, 6, 24, 3};
int len = sizeof(arr) / sizeof(int);
int temp[len];
CountSort(arr, len, temp);
display(temp, len);
}