View Single Post
Old Nov 26th, 2004, 4:25 PM   #2
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
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;
      }
   }
}
__________________
&quot;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.&quot; - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote