You could use an arrayList with the sort in the collections class, but if you don't want to do that, you could always use a simple bubble sort. Here's the general format:
for(int i = 0; i<array.length-1; i++)
{
for(int j = 0; j<array.length-1; j++)
{
if(array[j]>array[j+1])
{
int temp = array[j]; // int of course could be replaced with anything including your prisoner class
array[j] = array[j+1];
array[j+1] = temp;
}
}
}
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
|