We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int n=sc.nextInt();
// System.out.println(n);
String[] s=new String[n];
for(int i=0;i<n;i++){
s[i]=sc.next();
}
sc.close();
Arrays.sort(s, new Comparator<String>() {
@Override
public int compare(String a, String b) {
BigDecimal decimal1 = new BigDecimal(a);
BigDecimal decimal2 = new BigDecimal(b);
return +decimal2.compareTo(decimal1);
// return decimal2.compareTo(decimal1); for Asscending order write -
}
Java BigDecimal
You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.; import java.math.BigDecimal;
public class Solution {
});