please explain whats wrong with my code
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 void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> list = new ArrayList<String>();
while (true) {
String s = reader.readLine();
if (s.isEmpty()) break;
list.add(s);
}
String[] array = list.toArray(new String[list.size()]);
sort(array);
for (String x : array) {
System.out.println(x);
}
}
public static void sort(String[] array) {
// write your code here
ArrayList<Integer> num = new ArrayList<>();
ArrayList<String> str = new ArrayList<>();
ArrayList<Integer> pos_num = new ArrayList<>();
ArrayList<Integer> pos_str = new ArrayList<>();
for(int i = 0; i < array.length; i++)
{
boolean check_num = isNumber(array[i]);
if(check_num)
{
num.add(Integer.parseInt(array[i]));
pos_num.add(i);
}
else
{
str.add(array[i]);
pos_str.add(i);
}
}
for(int i = 0; i < str.size();i++)
{
for(int j = i+1; j < str.size(); j++)
{
String x = str.get(i);
String y = str.get(j);
if(isGreaterThan(x,y))
{
str.add(i,y);
str.add(j,x);
}
}
}
for(int i = 0; i < num.size(); i++)
{
for(int j = i+1; j < num.size(); j++)
{
int x = num.get(i);
int y = num.get(j);
if(x < y)
{
num.add(i,y);
num.add(j,x);
}
}
}
for(int i = 0; i< pos_num.size(); i++)
{
array[pos_num.get(i)] = Integer.toString(num.get(i));
}
for(int i = 0; i< pos_str.size(); i++)
{
array[pos_str.get(i)] = str.get(i);
}
}
// 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;
}
}