src/main/java/SampleClient.java
// sort list of patients in ascending order of first name
sort list of patients in ascending order of first name
sort list of patients in ascending order of first name
private static void sortList(ArrayList<Patient> patients) {
        int size = patients.size();
        for (int i = 0; i < size - 1; ++i) {
            String firstName = patients.get(i).getName().get(0).getGiven().get(0).toString();
            firstName = extractedFirstName(firstName);
            int indexToSwap = i;
            String lowestName = firstName;
            for (int j = i + 1; j < size; ++j) {
                String firstName2 = patients.get(j).getName().get(0).getGiven().get(0).toString();
                firstName2 = extractedFirstName(firstName2);
                if (firstName2.compareToIgnoreCase(lowestName) < 0) {
                    indexToSwap = j;
                    lowestName = firstName2;
                }
            }
            Collections.swap(patients, i, indexToSwap);
        }
    }
private static void sortList ( ArrayList < Patient > patients ) { int size = patients . size ( ) ; for ( int i = 0 ; i < size - 1 ; ++ i ) { String firstName = patients . get ( i ) . getName ( ) . get ( 0 ) . getGiven ( ) . get ( 0 ) . toString ( ) ; firstName = extractedFirstName ( firstName ) ; int indexToSwap = i ; String lowestName = firstName ; for ( int j = i + 1 ; j < size ; ++ j ) { String firstName2 = patients . get ( j ) . getName ( ) . get ( 0 ) . getGiven ( ) . get ( 0 ) . toString ( ) ; firstName2 = extractedFirstName ( firstName2 ) ; if ( firstName2 . compareToIgnoreCase ( lowestName ) < 0 ) { indexToSwap = j ; lowestName = firstName2 ; } } Collections . swap ( patients , i , indexToSwap ) ; } }
sort list of patients in ascending order of first name
sort list of patients in ascending order of first name
// look for patient with first name that lexicographically precedes the one at index i