How to get the sort the Alphanumeric and special character value in an Ascending order in Java

I have a input data like alphanumeric special character and i want to sort the data in an ascending order below is the input

$2M-$3M,
>$3M-$5M,
>$250K,
Up to $250k,
>$150k,
>$0,
>$5M,
Up to$500k,
>$2M,
>$1M,
Up to $150k,

and the expected output is as below

>$0
Up to $150k
>$150k
Up to $250k
>$250K
Up to $500k
>$1M
>$2M
$2M-$3M
>$3M-$5M
>$5M

Could you please do the need full below is the code which i have wrote

public static void main(String[] args) throws ParseException {
    ArrayList<String> listStrings = new ArrayList<>();

    String rules = "< 0 < 1 < 2 < '_'"; //etc

    listStrings.add("$2M-$3M");
    listStrings.add(">$3M-$5M");
    listStrings.add(">$250K");
    listStrings.add("Up to $250k");
    listStrings.add(">$150k");
    listStrings.add(">$0");
    listStrings.add(">$5M");
    listStrings.add("Up to $500k");
    listStrings.add(">$2M");
    listStrings.add(">$1M");
    listStrings.add("Up to $150k");

    for (int i = 0; i < listStrings.size(); i++) {

        System.out.println("Before Sort : "+listStrings.get(i));

    }
    System.out.println("=======================");
    Collections.sort(listStrings, new RuleBasedCollator(rules));


    for (int i = 0; i < listStrings.size(); i++) {

        System.out.println("After Sort : "+listStrings.get(i));

    }


}

A funky problem you have, but with a custom Comparator you can do the trick.

 Collections.sort(listStrings, new Comparator<String>() {
     @Override
     public int compare(String str1, String str2) {
        // convert to uppercase to ignore differences between upper and lower case 
        String str1up = str1.toUpperCase();
        String str2up = str2.toUpperCase();

        // if first str1 has no K or M and str2 has, str1 must be smaller than str2
        if((str1up.indexOf('K') < 0 && str1up.indexOf('M') < 0) && (str2up.indexOf('K') > 0 || str2up.indexOf('M') > 0)) {
           return -1;
        }

        // if first str1 has K or M and str2 has not, str1 must be bigger than str2
        if((str1up.indexOf('K') > 0 || str1up.indexOf('M') > 0) && (str2up.indexOf('K') < 0 && str2up.indexOf('M') < 0)) {
           return 1;
        }

        // if str1 has a K and str2 has a M, str1 must be smaller than str2 
        if(str1up.indexOf('K') > 0 && str2up.indexOf('M') > 0) {
           return -1;
        }
        // if str1 has a M and str2 has a K, str1 must be bigger than str2 
        if(str1up.indexOf('M') > 0 && str2up.indexOf('K') > 0) {
           return 1;
        }

        // split strings at $ for later comparision steps
        String[] split1 = str1up.split("//$");
        String[] split2 = str2up.split("//$");

        // if the beginning of str1 and str2 is the same, do further investigation
        if(split1[0].equals(split2[0])) {
           String lastCharOfStr1 = str1up.substring(str1up.length() - 1);
           String lastCharOfStr2 = str2up.substring(str2up.length() - 1);

           // if the last char of str1 and str2 is the same, there can be only a number between $ 
           // and the first occurence of the last char (according to given strings to sort)
           if(lastCharOfStr1.equals(lastCharOfStr2)) {
              String firstNumberValueOfStr1 = split1[1].split(lastCharOfStr1)[0];
              String firstNumberValueOfStr2 = split2[1].split(lastCharOfStr1)[0];
              // compare the numbers
              return new Integer(firstNumberValueOfStr1).compareTo(new Integer(firstNumberValueOfStr2));
           }
        }

        // if the second items of the split of str1 and str2 are equal 
        if(split1[1].equals(split2[1])) {
           // compare the first items of the split of str1 and str2 the other way round,
           // to sort ">" and "Up to " in the required manner
           return split2[0].compareTo(split1[0]);
        }

        // for the remaining cases, compare the second items of the split of str1 and str2
        return split1[1].compareTo(split2[1]);
     }
  });