Let's say I have an array of Employee objects.
A single employee object has parameters such as : name, age and department.
I need to sort the Employee objects by their age.
I know how to do this except for one part.
When I use the compareTo method, I need to specify how to sort the integers.
How would I do this with making them an array of integers or list?
EDIT
Here is my code to further clarify what I need to do.
public class Company {
public static void main(String [] args){
Employee[] e = new Employee[13];
PrimeAgeChecker p = new PrimeAgeChecker();
Department d = new Department();
e[0] = new Employee("Counting Guru",55,"Accounting");
e[1] = new Employee("Counting Pro",45,"Accounting");
e[2] = new Employee("Counting Savvy",40,"Accounting");
e[3] = new Employee("Counting Novice",25,"Accounting");
e[4] = new Employee("Sales Guru",50,"Marketing");
e[5] = new Employee("Sales Pro",48,"Marketing");
e[6] = new Employee("Sales Savvy",38,"Marketing");
e[7] = new Employee("Hiring Guru",58,"Human Resrouces");
e[8] = new Employee("Hiring Pro",47,"Human Resrouces");
e[9] = new Employee("Hacking Pro",47,"Information Systems");
e[10] = new Employee("Hacking Guru",51,"Information Systems");
e[11] = new Employee("Hacking Savvy",38,"Information Systems");
e[12] = new Employee("Hacking Novice",23,"Information Systems");
for(int i = 0;i<e.length;i++){
System.out.println(e[i] + " " + p.isPrime(e[i]));
}//end
}//end main
}//end company
As you can see, each Employee object takes 3 parameters.
I need to sort them by the integer which is their age.