package ru.pravvich.lesson_3;

import java.io.File;
import java.util.Arrays;
import java.util.Comparator;

public class CheckSort {
    public static void main(String[] args) {
        // сортировка первый способ
        String[] arr = {"ar","h","boot"};
        Comparator<String> stringLengthComparator = new StringLengthSort();
        Arrays.sort(arr,stringLengthComparator);
        System.out.println(Arrays.toString(arr));

        //короткий без отдельного класса хз как работает
        String[] arr1 = {"ar","h","boot"};
        Comparator<String> comprator = (o1,o2) -> o1.length() - o2.length();
        Arrays.sort(arr1,comprator);
        System.out.println(Arrays.toString(arr1));

    }

    private static class StringLengthSort implements Comparator<String> {
        @Override
        public int compare(String o1, String o2) {
            if (o1.length() > o2.length()) {
                return 1;
            } else {
                if (o1.length() < o2.length()) {
                    return -1;
                } else {
                    return 0;
                }
            }
        }
    }
}

@@ -252,84 +252,8 @@
 %22%7D;%0A
-        Comparator%3CString%3E stringLengthComparator = new StringLengthSort();%0A
     
@@ -272,17 +272,21 @@
 ort(arr,
-s
+new S
 tringLen
@@ -288,26 +288,22 @@
 ngLength
-Comparator
+Sort()
 );%0A     
@@ -780,108 +780,15 @@
     
-if (o1.length() %3E o2.length()) %7B%0A                return 1;%0A            %7D else %7B%0A                if (
+return 
 o1.l
@@ -795,17 +795,17 @@
 ength() 
-%3C
+-
  o2.leng
@@ -812,129 +812,9 @@
 th()
-) %7B%0A                    return -1;%0A                %7D else %7B%0A                    return 0;%0A                %7D%0A            %7D
+;
 %0A   

add two example for use Comparator