public voidSortDates // In this example the class Dogs has a date field // A getter method gets the date for the array of dog objects // The dates are compared and if necessary, swopped around { for(int i = 0; i < count - 1; i++) { for(int j = i + 1; j < count; j++) { if (myArray[i].getTheDate().isAfter(myArray[j].getTheDate() { Dogs temp= myArray[i]; myArray[i] = myArray[j]; myArray[j] = temp; } } } }