package com.ab.java8;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * Created by Abey on 10/19/2016.
 */
public class TestLambda {

    public static void main(String[] args) {
        test1();
    }

    public static final void test1()
    {
        List<String> names = Arrays.asList("peter", "anna", "mike", "xenia");
        System.out.println("names 1:" + names);
        Collections.sort(names, new Comparator<String>() {
            @Override
            public int compare(String a, String b) {
                return a.compareTo(b);
            }
        });
        System.out.println("names 2:" + names);
        Collections.sort(names, (String a, String b) -> {
                    return a.compareTo(b);
                }
        );
        System.out.println("names 4:" + names);
        Collections.sort(names, (String a, String b) -> b.compareTo(a));
        System.out.println("names 5:" + names);
        Collections.sort(names, (a, b) -> a.compareTo(b));
        System.out.println("names 6:" + names);
    }

}
