title: java - sort ascending
body: <p>well my java project is nearly finished, but having one more part to deal with, sorting.  I have to use sorting in ascending order based on an ID number of an employee.  I'm not sure what kind of sort to use, and where to implement it.  Create a new class for it? Let me show you my tester code.  I have faculty/partime//staff/education classes all working.  Code from those classes all show up in TestEmployee.  So any help/tips is appreciated on how to sort my ID numbers.</p>
  
  <pre><code>import java.util.Calendar;
  import java.util.Scanner;
  
  public class TestEmployee implements EmployeeInfo{
  
  
          public static void main(String[] args) throws CloneNotSupportedException {
  
          /**
           * Part A: output all employee from Staff, Faculty, and partime.
           */
  
          double sum=0,total=0;
  
                  Employee[]emp = new Employee[9];
                  Calendar staffBirthDate = Calendar.getInstance();
                  Calendar facultyBirthDate = Calendar.getInstance();
                  Calendar partimeBirthDate = Calendar.getInstance();
  
                  staffBirthDate.set(1959, 2, 23);// Scott Chan
                  emp[0] = new Staff("Chan, Scott", 123, 'M', staffBirthDate, 35.00);
  
                   staffBirthDate = Calendar.getInstance();
  
                  staffBirthDate.set(1964, 7, 12);// Brian Salinas
                  emp[1] = new Staff("Salinas, Brian", 456, 'F', staffBirthDate, 30.00);
  
                   staffBirthDate = Calendar.getInstance();
  
                  staffBirthDate.set(1970, 6, 2);// Allen Weir
                  emp[2] = new Staff("Weir, Allen", 789, 'M', staffBirthDate, 22.00);
  
                  facultyBirthDate = Calendar.getInstance();
  
                  facultyBirthDate.set(1962, 4, 27);
                  emp[3] = new Faculty("Im, Lee", 243, 'F', facultyBirthDate, "Full", "PH.D", "Engineering", "3");
  
                  facultyBirthDate = Calendar.getInstance();
  
                  facultyBirthDate.set(1975, 3, 14);// 
                  emp[4] = new Faculty("Bui, Thung", 791, 'F', facultyBirthDate, "Associate", "PH.D", "English", "1");
  
                  facultyBirthDate = Calendar.getInstance();
  
  
                  facultyBirthDate.set(1980, 5, 22);//
                  emp[5] = new Faculty("Monreno, Maria", 623, 'F', facultyBirthDate, "Assistant", "MS", "Physical Education", "0");
  
                   partimeBirthDate = Calendar.getInstance();
  
                   partimeBirthDate.set(1977, 8, 10);
                  emp[6] = new Partime("Lee, Chesong", 455, 'F', partimeBirthDate, 20, 35.00);
  
                   partimeBirthDate = Calendar.getInstance();
  
  
                          partimeBirthDate.set(1987, 9, 15);
                  emp[7] = new Partime("Garcia, Frank", 678, 'M', partimeBirthDate, 25, 30.00);
  
                   partimeBirthDate = Calendar.getInstance();
  
                          partimeBirthDate.set(1980, 8, 22);//
                  emp[8] = new Partime("Alquilo, Roscoe", 945, 'M', partimeBirthDate, 30, 20.00);
  
                  for(int i = 0; i&lt;emp.length;i++)
          {
              if(emp[i] instanceof Staff)
              {
                  System.out.println("\n"+emp[i]);
              }//end of if statement
              if(emp[i] instanceof Faculty)
              {
                  System.out.println("\n"+emp[i]);
              }//end of if statement
  
          }// end of for loop
  
                  for(int i = 0; i&lt;emp.length; i++)
                  { 
                      sum = ((Employee) emp[i]).monthlyEarning()+sum;
                  }
                  System.out.println("\nTotal monthly salary for all Employees");
  
                  System.out.println("$"+sum);
                  //c
                  System.out.println("\nTotal monthly salary for all faculuty");
                  for(int i = 0; i&lt;emp.length;i++)
                  {
                      if(emp[i] instanceof Faculty)
                      {
                          total = ((Employee) emp[i]).monthlyEarning()+total;
                      }
                  }
                  System.out.println("$"+total);
                // Duplicate a faculty object. test the duplication
                  Faculty f1 = (Faculty)emp[4];
                  Faculty f2 = (Faculty)f1.clone();
                  Education dupl = new Education("PH.D",
                          "Doctor", "4");
                  f2.setEducation(dupl);
                  System.out.println("\nD Duplicate a Faculty Object"
                          +"\n"+f2.toString());
  
                  // Verify two staff objects are the same
  
                  System.out.println("\nE.Verify two staff objects ");
                  Staff s1 = (Staff)emp[6];
                  Staff s2 = (Staff)s1.clone();
                           staffBirthDate = Calendar.getInstance();
  
                  Staff s3 = new Staff("Danger, Norman", 456, 'M', staffBirthDate, 25.00);
                  if(s1.getBirthdate()==s2.getBirthdate())
                  {
                      System.out.print("\nThe two staff objects " +
                              " birthdays"+ " are the same "
                              +"therefore "+true+"\n");
                  }
                  if(s3.getBirthdate()==s1.getBirthdate())
                  {
                      System.out.print(true);
                  }
  
                  // Sort employees by ascending employee ID
                  System.out.println("\nSort employees by ID");
  
  
                  {
                      System.out.println("\n"+emp[i]);
                  }
          }
  }
  </code></pre>