Sorting a 2-dimensional array with counting sort
Algorithm is ok, and there is nothing faster than counting sort. You just need to use single System.out.print:

StringBuilder sb = new StringBuilder();
for (int i = 0; i &lt; result.length; i++) {
    sb.append(result[i]).append(" ");
}
System.out.print(sb.toString());


It is faster than many separate calls;