Alternative code to sort substrings
function substringSort ( arr , n , maxLen ) { let count = new Array ( maxLen ) ; let sortedArr = new Array ( maxLen ) ; count . fill ( 0 ) ; for ( let i = 0 ; i < maxLen ; i ++ ) { sortedArr [ i ] = " " ; }