package ru.job4j.comparator;

import java.util.Comparator;
/**
 * ListCompare class.
 *
 * @author Kuzmin Danila (mailto:bus1d0@mail.ru)
 * @version $Id$
 * @since 0.1.3
 */
public class ListCompare implements Comparator<String> {
    /**
     * Compare method.
     * @param o1 - first String.
     * @param o2 - second String.
     * @return int -1,0,1.
     */
    @Override
    public int compare(String o1, String o2) {
        int toReturn = 0;
        int lengthO1 = o1.length();
        int lengthO2 = o2.length();
        char[] o1Char = o1.toCharArray();
        char[] o2Char = o2.toCharArray();
        if (lengthO1 == lengthO2) {
            for (int i = 0; i < lengthO1; i++) {
                if (o1Char[i] != o2Char[i]) {
                    toReturn = o1Char[i] - o2Char[i];
                }
            }
        } else {
            toReturn = lengthO1 - lengthO2;
        }
        if (toReturn > 0) {
            toReturn = 1;
        } else if (toReturn < 0) {
            toReturn = -1;
        }
        return toReturn;
    }
}

@@ -604,48 +604,8 @@
 ();%0A
-        if (lengthO1 == lengthO2) %7B%0A    
     
@@ -641,28 +641,24 @@
 hO1; i++) %7B%0A
-    
             
@@ -695,36 +695,32 @@
                 
-    
 toReturn = o1Cha
@@ -753,24 +753,18 @@
     
- 
-   %7D%0A  
+%7D%0A
         
   %7D%0A
@@ -751,35 +751,34 @@
       %7D%0A        
-  
 %7D
+%0A
 %0A        %7D else 
@@ -770,23 +770,31 @@
         
-%7D else 
+if(toReturn==0)
 %7B%0A      
@@ -833,32 +833,33 @@
 thO2;%0A        %7D%0A
+%0A
         if (toRe

Исправить ListCompare