I have sentence . how can group this based on character length? : 



    public class sortingtext {
    
    	public static void main(String[] args) throws IOException {
        		String  readline="i have a sentence with words";
        		String[] words=readline.split(" ");
        		
        		Arrays.sort(words, (a, b)->Integer.compare(b.length(), a.length()));
            
        		for (int i=0;i<words.length;i++)
        		{
        			int len = words[i].length();
        		
        			int t=0;
        			    			
        			System.out.println(len +"-"+words[i]);
        		}
        		
        	}

   input: i have a sentence with words
    when i tried i got it like
    8- sentence 
    5- words
    4- have 
    4-with 
    1-I 
    1-a
Expected output:

8- sentence 
5- words
4- have ,with 
1-I a