[Solved] Why does my sorting method for Bigdecimal numbers fails to sort?

[ad_1]

Well, since you want to use String numbers, you will have to wrap them in quotations, but your sorting can be much more readable. I would suggest the following

    String[] numbers ={"-100", "50", "0", "56.6", "90", "0.12", ".12", "02.34", "000.000"};
    List<BigDecimal> decimalList = new ArrayList<>();
    for(String s: numbers){
        decimalList.add(new BigDecimal(s));
    }
    Collections.sort(decimalList);
    Collections.reverse(decimalList);     // edit , forgot this line
    decimalList.forEach(System.out::println);

1

[ad_2]

solved Why does my sorting method for Bigdecimal numbers fails to sort?