title: How to rearrange elements in a collection of bean for a partciular value
body: <p>Let's say i have a collection of bean and it's sorted by empld, dept, project with the help of custom comparator written for it and using apache collection ComparatorChain to sort the list of this bean. The bean is as follows.</p>
  
  <pre><code>public class Employee  {
  
      protected String empId; //alphanumeric e.g.abc123
      protected String empFullName;   
      protected String empAddress;
      protected String dept;
      protected String project;
      protected String customer;
  
      public String getEmpId() {
          return empId;
      }
      public void setEmpId(String empId) {
          this.empId = empId;
      }
      public String getEmpFullName() {
          return empFullName;
      }
      public void setEmpFullName(String empFullName) {
          this.empFullName = empFullName;
      }
      public String getEmpAddress() {
          return empAddress;
      }
      public void setEmpAddress(String empAddress) {
          this.empAddress = empAddress;
      }
      public String getDept() {
          return dept;
      }
      public void setDept(String dept) {
          this.dept = dept;
      }
      public String getProject() {
          return project;
      }
      public void setProject(String project) {
          this.project = project;
      }
  
      public String getCustomer() {
          return customer;
      }
      public void setCustomer(String customer) {
          this.customer = customer;
      }
  
  
  }
  </code></pre>
  
  <p>The customer values can be, let's say: Company, Government, University</p>
  
  <p>Now let's say there are thousands of records(beans) in the collection and now what i want is for same empId (which can appear twice) if the customer is Company move that below the same empId with customer name University. The records of customer might not be in order might, so any one can appear first etc.</p>
  
  <p>So basically i want to move if two or more records with same empId and one of them has customer =Company move that to the below the order with same empId
  e.g.</p>
  
  <p><img src="https://i.stack.imgur.com/iPtA9.jpg" alt="Custom Sort"></p>
  
  <p>How can i achieve this swapping/rearranging of records in an efficient and possible thread safe way.</p>