Soltion for counting sort