title: Reading three words and sorting them in lexicographic order
body: <p>I am trying to create a program that asks the User to type three words and sort them in lexicographic order. </p>
  
  <p>EXAMPLE;</p>
  
  <blockquote>
    <ul>
    <li>Enter three words separated by spaces:</li>
    <li>Pear Orange Apple</li>
    <li>Apple</li>
    <li>Orange </li>
    <li>Pear</li>
    </ul>
  </blockquote>
  
  <p>The program is working fine (if I attempt the above example) except for one type of combination example that I will show below.</p>
  
  <p>EXAMPLE;</p>
  
  <blockquote>
    <ul>
    <li>Enter three words separated by spaces:</li>
    <li>Orange Apple Pear </li>
    <li>Apple</li>
    <li>Pear</li>
    <li>Pear</li>
    </ul>
  </blockquote>
  
  <p>The program is skipping the first word (Orange) if it is supposed to appear in the middle of the three words. </p>
  
  <p>I believe that this line of code is affecting the program because it says that "this assigned value is never used" but I'm not sure how to fix it since I'm still an entry Java learner.</p>
  
  <blockquote>
    <ul>
    <li>middle = firstWord;</li>
    </ul>
  </blockquote>
  
  <p>Because of that line being unused, it's why Pear appeared twice.</p>
  
  <pre><code>import java.util.*;
  public static void main(String[] args) 
  {
  
  Scanner wordInput = new Scanner(System.in);
  String firstWord;
  String secondWord;
  String thirdWord;
  
  
  System.out.println("Enter three words separated by spaces: ");
  
  firstWord = wordInput.next();
  secondWord = wordInput.next();
  thirdWord = wordInput.next();
  
  
  String top = firstWord;
  String bottom = firstWord;
  if( top.compareTo(secondWord) &gt; 0) 
  { 
  top = secondWord; 
  } 
  if( top.compareTo(thirdWord) &gt; 0) 
  { 
  top = thirdWord; 
  } 
  if( bottom.compareTo(secondWord) &lt; 0) 
  { 
  bottom = secondWord; 
  } 
  if( bottom.compareTo(thirdWord) &lt; 0) 
  { 
  bottom = thirdWord; 
  }   
  String middle;
  if( !firstWord.equals(bottom) &amp;&amp; !firstWord.equals(top) ) 
  { 
  middle = firstWord; 
  } 
  if( !secondWord.equals(bottom) &amp;&amp; !secondWord.equals(top) ) 
  { 
  middle = secondWord; 
  } 
  else 
  { 
  middle = thirdWord; 
  } 
  
  System.out.println( top ); 
  System.out.println( middle ); 
  System.out.println( bottom ); 
  
  
  }
  }
  </code></pre>
  
  <p>Does anyone what I am missing or doing wrong? :(
  Please and thank you for any help!    </p>