Sorting the array of strings on their lengths in Java , Using Maps, ascending order....
I think you can use the Arrays.sort with Comparator to make this simple. just Override the comparator to compare the length of the array like this

public static String[] sortStrArray(String[] array){
   //sort arrays by length before returning
    Arrays.sort(array, new Comparator&lt;String&gt;() {
        @Override
        public int compare(String a, String b) {
            return Integer.compare(a.length(),b.length());//specifying compare type that is compare with length
        }
    });
     return array;
}


///Main Method here

String[] str = {"James","Ana","Michael","George","rose"};
    System.out.println(Arrays.toString(sortStrArray(str)));


Output:


  [Ana, rose, James, George, Michael]


with Java 8

 public static String[] sortStrWithLam(String[] array){
    //sort arrays by length before returning
    Arrays.sort(array,(a,b) -&gt; Integer.compare(a.length(),b.length()));
    return array;
}