diff --git a/Java/javabig_decimal.java b/Java/javabig_decimal.java new file mode 100644 index 0000000..cf0b87c --- /dev/null +++ b/Java/javabig_decimal.java @@ -0,0 +1,12 @@ +Arrays.sort(s, Collections.reverseOrder(new Comparator() { + @Override + public int compare(String a1, String a2) { + //convert to big decimal inside comparator + //so permanent string values are never changed + //aka you only use the BigDecimal values to + //compare the strings! + BigDecimal a = new BigDecimal(a1); + BigDecimal b = new BigDecimal(a2); + return a.compareTo(b); + } +}));