Here is an implementation of counting sort in c++11. It does not give any output. What possibly went wrong? Should not the std::copy copies back the sorted array to the original array?
void counting_sort::sort_array(int array[], int n)
{
std::vector <int> a;
a.insert(a.end(), &array[0], &array[n]);
std::vector <int> b;
auto k = *std::max_element(a.begin(), a.end());
auto m = *std::min_element(a.begin(), a.end());
auto x = k - m + 1;
std::vector<int>v(x);
for(int i = 0; i < a.size(); i++)
v[a[i]-m]++;
for(int i = 1; i < v.size(); i++)
v[i]=v[i]+v[i-1];
for(int i = a.size()-1; i >= 0; i--)
{
b[v[a[i]-m]-1] = a[i];
v[a[i]-m]--;
}
std::copy(b.begin(), b.end(), array);
}