Alternative code to sort substrings
import java . util . Arrays ; public class Demo { public static void substringSort ( String [ ] arr , int n , int maxLen ) { int count [ ] = new int [ maxLen ] ; String [ ] sortedArr = new String [ maxLen ] ; Arrays . fill ( count , 0 ) ; Arrays . fill ( sortedArr , " " ) ;