I have an ArrayList with a couple of simple user objects in it which contains information such as their ID, name, and password:
user1 = new User(19, "bsmith", "password");
user2 = new User(15, "jbrown", "password");
user3 = new User(23, "sgreen", "password");
userArray.add(person1);
userArray.add(person2);
userArray.add(person3);
I'm trying to sort them by their user ID using this bubble sort method I found:
public static void BubbleSort( int [ ] num )
{
 int j;
 boolean flag = true;   
 int temp;   
 while ( flag )
 {
        flag= false;    
        for( j=0;  j < num.length -1;  j++ )
        {
               if ( num[ j ] > num[j+1] )   
               {
                       temp = num[ j ];                
                       num[ j ] = num[ j+1 ];
                       num[ j+1 ] = temp;
                      flag = true;              
              }
        }
  }
} 
I just have no idea how to actually use it on my ArrayList. I managed to get it to sort a regular array though:
int j[] = {10,30,20,50};
People p = new People();
p.BubbleSort(j);
for (int i = 0; i < j.length; i++) {
    System.out.println(j[i]);
}
My question: Is it possible to use the bubble sort directly on the ID of each user in my ArrayList, or do I have to somehow put each users's ID into another array and use the bubble sort method on that?
 
     
     
    