title: Order the elements of array list in Java
body: <p>I have an arraylist defined whose elements are say, <code>[man, animal, bird, reptile]</code>. The elements in the arraylist are non-mandatory. The list can even be empty. </p>
  
  <p>I always need to give the output as <code>[animal,man,reptile,bird]</code>. Means, the order of the elements are to be maintained. Is there any way of doing in arraylist?</p>
  
  <p>I thought I can do like</p>
  
  <pre><code>for (String listElement: customList) { //custom list variable holds all elements
      if (listElement.equalsIgnoreCase("animal"){
          newList.add(0, listElement);
  } else if("man") {
      newlist.add(1, listElement);
  }
  </code></pre>
  
  <p>But I would want to know the best practice of doing. Can someone please help me on this? </p>