package com.vidyasource.tutorial.comparison;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ComparisonShopper {
    public static void main(String[] args) {
        List<Car> cars = new ArrayList<>();
        cars.add(new Car(75000, "Mercedes"));
        cars.add(new Car(90000, "Audi"));
        cars.add(new Car(65000, "BMW"));

        Collections.sort(cars);
        System.out.print("Natural sorting on price: ");
        for (Car car : cars) {
            System.out.print(car + " ");
        }
        System.out.println("");
        Collections.sort(cars, new MakeComparator());
        System.out.print("Comparator sorting on make: ");
        for (Car car : cars) {
            System.out.print(car + " ");
        }
    }
}

@@ -195,24 +195,494 @@
 g%5B%5D args) %7B%0A
+        printCarMakes();%0A        printCars();%0A    %7D%0A%0A    private static void printCarMakes() %7B%0A        List%3CString%3E makes = new ArrayList%3C%3E();%0A        makes.add(%22Mercedes%22);%0A        makes.add(%22Audi%22);%0A        makes.add(%22BMW%22);%0A%0A        Collections.sort(makes);%0A        System.out.print(%22Sorted strings: %22);%0A        for (String make : makes) %7B%0A            System.out.print(make + %22 %22);%0A        %7D%0A        System.out.println();%0A    %7D%0A%0A    private static void printCars() %7B%0A
         List
@@ -705,32 +705,32 @@
  ArrayList%3C%3E();%0A
-
         cars.add
@@ -1044,10 +1044,8 @@
 tln(
-%22%22
 );%0A 
@@ -1237,16 +1237,18 @@
       %7D%0A
-
     %7D%0A
+%0A%0A
 %7D%0A

Add String sorting