Modified bucket sort
Pointless loops

You have a couple of loops that do nothing but waste time:


     while (val != iterator)
       iterator--;



That loop does the same thing as:

    iterator = val;


Similarly, this loop:


         while (counter &lt; value)
         counter++;



is the same as:

         counter = value;


Way too complicated

Your code that fills the buckets is confused and complicated:


 for (int j = 0; j &lt; vectSize; j++)
   {
     int val = 0;
     int count = 0;
     int element = 0;
     int iterator = M;
     val = V[j];
     while (val != iterator)
       iterator--;
     element = iterator + M;
     count = U[element];
     count++;
     U[element] = count;
   }



It should really be a one line loop:

for (int j = 0; j &lt; vectSize; j++) {
    U[V[j]]++
}


Note that this uses buckets in the range 0..M, whereas yours uses buckets in the range M..2M for no good reason.

Similarly, your bucket unpacking loop could be simplified to:

int index = 0;
for (int i = 0; i &lt;= M; i++) {
    for (int j = 0; j &lt; U[i]; j++) {
        V[index++] = i;
    }
}


This assumes that you allocated U to hold M+1 elements, to allow for values in the range 0..M.