package cokr.xit.problems;

import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.Collections;

public class Sort {
    @Test
    public void fncSortInteger(){
        int[] nums  = {21,31,19,4,16};

        System.out.println("==================================");
        System.out.println("index 2 부터 정렬");
        System.out.println("==================================");
        Arrays.sort(nums, 2, nums.length);
        Arrays.stream(nums).asLongStream()
                .forEach(System.out::println);


        System.out.println("==================================");
        System.out.println("index 0 부터 정렬");
        System.out.println("==================================");
        Arrays.sort(nums);
        Arrays.stream(nums).asLongStream()
                .forEach(System.out::println);


        System.out.println("==================================");
        System.out.println("내림차순(desc)  정렬");
        System.out.println("==================================");
        Integer[] nums2 = {4,2,1,5,3};
        Arrays.sort(nums2, Collections.reverseOrder());
        Arrays.stream(nums2)
                .forEach(System.out::println);
    }

    @Test
    public void fncSortString(){
        String[] strs  = {"efg","dab","bff","abc",};

        System.out.println("==================================");
        System.out.println("index 2 부터 정렬");
        System.out.println("==================================");
        Arrays.sort(strs, 2, strs.length);
        Arrays.asList(strs).stream()
                .forEach(System.out::println);


        System.out.println("==================================");
        System.out.println("index 0 부터 정렬");
        System.out.println("==================================");
//        Arrays.sort(strs);
        Arrays.asList(strs).stream()
                .sorted()
                .forEach(System.out::println);


        System.out.println("==================================");
        System.out.println("내림차순(desc)  정렬");
        System.out.println("==================================");
        Arrays.sort(strs, Collections.reverseOrder());
        Arrays.asList(strs).stream()
                .forEach(System.out::println);
    }
}
