The array is valid and sorted print the strings in order
for ( let i = 0 ; i < maxLen ; i ++ ) { let s = sortedArr [ i ] ; for ( let j = 0 ; j < count [ i ] ; j ++ ) { document . write ( s + " " ) ; } } }