title: Adding to a linked list in the right alphabetical position
body: <p>My assignment is to modify the below code so it positions new elements alphabetically in the linked list. It currently adds the element to the end of the list.</p>
  
  <pre><code>public void add(String element) {
      Node newNode = new Node(element);
      if (first == null)
          first = newNode;
      else {
          // Find the predecessor of the element to add
          Node current = first;
          Node prev = null;
          while (current != null) {
              prev = current;
              current = current.next;
          }
          // New last element 
          if (current == null) 
              prev.next = newNode;
          else if (prev == null) {
              newNode.next = first;
              first = newNode;
          }
      }
  }
  </code></pre>