need hint
package com.codegym.task.task09.task0930;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Task about algorithms
*/
public class Solution {
public static boolean a = false;
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> list = new ArrayList<String>();
if(!a) {while (true) {
String s = reader.readLine();
if (s.isEmpty()) break;
list.add(s);
}}
else {list.add("gart");
list.add("12");
list.add("krr");
list.add("2");
list.add("ber");
list.add("utr");
list.add("88");
list.add("frb");}
String[] array = list.toArray(new String[list.size()]);
sort(array);
for (String x : array) {
System.out.println(x);
}
}
public static void sort(String[] array) {
ArrayList<String> string = new ArrayList<>();
ArrayList<String> number = new ArrayList<>();
ArrayList<Integer> poparse = new ArrayList<>();
for(int i = 0; i<array.length; i++){
if(isNumber(array[i])){
number.add(array[i]);
}
else string.add(array[i]);
}
for(int i = 0; i<number.size(); i++){
poparse.add(Integer.parseInt(number.get(i)));
}
String[] a = new String[string.size()];
a = string.toArray(a);
for(int i=0; i<a.length; i++){
for(int j = i+1; j<a.length; j++){
if(isGreaterThan(array[i], array[j])){
String w =array[j];
array[j]=array[i];
array[i]=w;
}
}
}
Integer[] e = new Integer[poparse.size()];
e = poparse.toArray(e);
for(int i = 0; i<e.length; i++){
for(int j = i+1; i<e.length; i++){
if(e[j]>e[i]){
int w = e[j];
e[j] = e[i];
e[i]=w;
}
}
}
}
// String comparison method: 'a' is greater than 'b'
public static boolean isGreaterThan(String a, String b) {
return a.compareTo(b) > 0;
}
// Is the passed string a number?
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 == '-') // The string contains a hyphen
|| (!Character.isDigit(c) && c != '-') // or is not a number and doesn't start with a hyphen
|| (i == 0 && c == '-' && chars.length == 1)) // or is a single hyphen
{
return false;
}
}
return true;
}
}