/Users/johnr/Dropbox/johnrayworth.info/largeFilesOutsideJSR/__IB-Other/Other/IA-Solutions-2019/TigerBee/Product/Computer Science Ia/src/computer/science/ia/SortAndSearchFlight.java |
1
2
3
4
5
6 package computer.science.ia;
7
8 import java.util.ArrayList;
9
10
11
12 @author
13
14 public class SortAndSearchFlight {
15
16 public void selectionSortOfFlightCodes(ArrayList<Flight> flights) {
17 for (int i = 0; i < flights.size() - 1; i++) {
18 int minIndex = i;
19 for (int j = i + 1; j < flights.size(); j++) {
20 if (flights.get(j).getCityCode().compareTo(flights.get(minIndex).getCityCode()) < 0) {
21 minIndex = j;
22 }
23 }
24 if (minIndex != i) {
25
26
27 Flight temp = flights.get(i);
28 flights.set(i, flights.get(minIndex));
29 flights.set(minIndex, temp);
30 }
31 }
32 }
33
34 }
35