Optimized CountingSort using list generator