title: using doubly linked list to process a text
body: <p>I have to read a paragraph containing words from an input file. then create a doubly linked list containing the distinct words read, where the words of the same length are placed in the same list, in ascending order.</p>
  
  <p>So i tried to create an array of doubly linked list, I know how to add the words but I can't sort them in ascending order.(we have to sort the words while adding them, not sorting the text then adding.)</p>
  
  <pre><code>int x = max(s);
  DoublyLinkedList[] list = new DoublyLinkedList[x];
          for (int i = 0; i &lt; list.length; i++) {
              list[i] = new DoublyLinkedList();
          }
  
  public static void m(DoublyLinkedList[] list, String s) {
  
          String[] s1 = s.split(" ");
  
          for (int i = 0; i &lt; s1.length; i++) {
              list[s1[i].length()].addLast(s1[i]);
  
          }
      }
  
      public static int max(String s) {
          String[] s1 = s.split(" ");
          int max = s1[1].length();
          for (int i = 0; i &lt; s1.length; i++) {
              if (s1[i].length() &gt; max) {
                  max = s1[i].length();
              }
          }
          return max + 1;
      }
  </code></pre>