title: Java 1.6: Sorting a List of models basel on a model value
body: <p>I am using java 1.6. I have a <code>Employee</code> model as shown below:</p>
  
  <pre><code>private String id;
  private String firstName;
  private String lastName;
  private String phoneNumber;
  //getters and setters
  </code></pre>
  
  <p>The <code>List&lt;Employee&gt;</code> contains all the employee data fetch from the DB.</p>
  
  <p>I need to search for one or more employees present within the <code>List&lt;Employee&gt;</code> (something like a employee search functionality, search has to be done on the <code>List&lt;Employee&gt;</code> rather than another DB hit with search criteria). As of now, I don't want any DB hit for searching the employee from the <code>List&lt;Employee&gt;</code>. But if it becomes complicated then I have to go for the db hit.</p>
  
  <p>Right now whatever I have thought of is a sluggish logic like: Iterate through the <code>List&lt;Employee&gt;</code> and for each <code>Employee</code> keep on searching for the values of search criteria, if it matches then add it to a new <code>List&lt;Employee&gt;</code> (this will give me the search result).</p>
  
  <p>I want to know if there is some optimal way of achieving the same. Please let me know about this.</p>