Copy the output array to [ ] arr , so that [ ] arr now contains sorted numbers according to current digit
for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { arr [ i , j ] = ans [ i , j ] ; } }