title: Comparing two string and sorting them in alphabetical order
body: <p>I want to compare two strings and sort them in alphabetical order. I am currently creating two arrays with the strings and sorting one them comparing the two arrays.</p>
  
  <pre><code>String a="LetterA";
  String b="ALetterB";
  String[] array1={a.toLowerCase(),b.toLowerCase()};
  String[] array2={a.toLowerCase(),b.toLowerCase()};
  Arrays.sort(array2);
  if (Arrays.equals(array1, array2)){
      System.out.println(a+" is before "+b);
  }
  else{
      System.out.println(b+" is before "+a);
  }
  </code></pre>
  
  <p>This works but it is time and memory consuming. I would appreciate if anyone can suggest a better way to do this.</p>