title: radix sort array of strings
body: <p>I am trying to use radix sort to sort file contain social security and date     of birth the format looks like this "###-##-####,#######.I have to apply radix sort on each fields according to command line switch. I have a radix sort that is work for int array and i am trying to modify the code for string type array but i am not sure how to accomplish this. I did a quick sort for string type by comparing strings and pivot and that is work fine however for radix sort I am not if I can do this with string type or I have to convert the string to integer. I have tried to use "atoi" to convert to integer but I am not sure how to correctly do this if I have to.  </p>
  
  <pre><code>   string getMax(string arr[], int n){
      string max = arr[0];
      for (int i = 1; i &lt; n; i++){
          if (arr[i]&gt;max)
              max = arr[i];
      }
      return max;
     }
  
     void countSort(string a[], int size, int k){
      string *b = NULL; int *c = NULL;
      b = new string[size];
      c = new int[k]; 
  
  
  
      for (int i = 0; i &lt;k; i++){
          c[i] = 0;
          //cout &lt;&lt; c[i] &lt;&lt; "\n";
      }
      for (int j = 0; j &lt;size; j++){   
          c[(a[j]/k)%10]++;            //a[j] is a string
          //cout &lt;&lt; c[a[j]] &lt;&lt; endl;
      }
  
      for (int f = 1; f &lt;10; f++){
          c[f] += c[f - 1];
      }
  
      for (int r = size - 1; r &gt;= 0; r--){
          b[c[(a[r] / k) % 10] - 1] = a[r];
          c[(a[r] / k) % 10]--;
      }
  
      for (int l = 0; l &lt; size; l++){
          a[l] = b[l];
      }
  
      }
  
  
      void radixSort(string b[], int r){
      string max = getMax(b, r);
      for (int digit = 1; max / digit &gt; 0; digit *= 10){
          countSort(b, r, digit);
      }
  
      };  
  </code></pre>