В Intellij IDEA все спокойно работает
package com.javarush.task.task09.task0930;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> list = new ArrayList<>();
while (true){
String s = reader.readLine();
if (s.isEmpty()) break;
list.add(s);
}
String[] array = list.toArray(new String[0]);
sort(array);
for (String x: array) System.out.println(x);
}
public static void sort(String[] array) {
String buf = "";
boolean s = true;
while (s) {
s = false;
for (int i = 0; i < array.length; i++) {
if (isNumber(array[i])) {
for (int j = i; j < array.length; j++) {
if (isNumber(array[j])) {
if (isGreaterThan(array[j], array[i])) {
buf = array[i];
array[i] = array[j];
array[j] = buf;
s = true;
}
}
}
} else {
for (int j = i; j < array.length; j++) {
if (!isNumber(array[j])) {
if (isGreaterThan(array[i], array[j])) {
buf = array[i];
array[i] = array[j];
array[j] = buf;
s = true;
}
}
}
}
}
}
}
public static boolean isGreaterThan(String a, String b){
return a.compareTo(b) > 0;
}
public static boolean isNumber(String s){
if (s.length() == 0) return false;
char[] chars = s.toCharArray();
for (int i = 0; i < chars.length; i++){
char c = chars[i];
if ((i != 0 && c == '-') || (!Character.isDigit(c) && c != '-') || (chars.length == 1 && c == '-')) return false;
}
return true;
}
}