title: How to sort ArrayList alphabetically in Java without using collections?
body: <p>I have the following code which takes names and stores them in an ArrayList.</p>
  
  <pre><code>class Main{
    public static void main(String[] args) {
      ArrayList&lt;String&gt; names = new ArrayList&lt;String&gt;();
      Scanner scan = new Scanner(System.in);
      String name;
      do{
        System.out.println("Enter the next name: ");
        name = scan.nextLine();
        String toUpperCase = titleCase(name);
        if(!toUpperCase.equals("Stop")){
          names.add(toUpperCase);
        }
      } while(!name.equalsIgnoreCase("STOP"));
  
      System.out.println(names);
  
  
    }
    public static String titleCase(String s){
      String output = s.substring(0, 1).toUpperCase() +     s.substring(1).toLowerCase();
      return output;
    }
  </code></pre>
  
  <p>}</p>
  
  <p>I need to sort the ArrayList alphabetically by name without using Collections.</p>