/Users/johnr/Desktop/IA_14_-_Stage_P_Upload_all_2021-04-08/RugbyIA Pune April 7th/src/Sort.java |
1
2
3
4
5
6
7
8
9 @author
10
11 public class Sort {
12 public void sortByGameNumber(Game[] gamesArray, int counter) {
13 int n = counter;
14 boolean sorted = false;
15 while (!sorted) {
16 n--;
17
18 sorted = true;
19 for (int i=0; i < n; i++) {
20 if (gamesArray[i].getGameNumber().compareTo(gamesArray[i+1].getGameNumber()) > 0) {
21 Game temp = gamesArray[i];
22 gamesArray[i] = gamesArray[i+1];
23 gamesArray[i+1] = temp;
24 sorted = false;
25
26
27 }
28 }
29 }
30 }
31 }
32
33
34