The program works correctly, but it wont verify.
package com.codegym.task.task08.task0830;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
/*
Task about algorithms
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String[] array = new String[20];
for (int i = 0; i < array.length; i++) {
array[i] = reader.readLine();
}
sort(array);
for (String x : array) {
System.out.println(x);
}
}
public static void sort(String[] array) {
//write your code
String s = "";
for (int i = array.length -1; i > 0; i--) {
for (int j = 1; j < i; j++) {
if (isGreaterThan(array[j-1], array[j])) {
s = array[j];
array[j] = array[j-1];
array[j-1] = s;
}
}
}
}
// String comparison method: 'a' is greater than 'b'
public static boolean isGreaterThan(String a, String b) {
return a.compareToIgnoreCase(b) > 0;
}
}