fork download
  1. import java.util.*;
  2. import java.util.Arrays;
  3. import java.util.Collections;
  4.  
  5. class Mahesh{
  6. public static void main(String args[]){
  7. Scanner sc = new Scanner(System.in);
  8. int n;
  9. n=sc.nextInt();
  10. int a[]=new int[n];
  11. for(int i=0;i<n;i++){
  12. a[i]=sc.nextInt();
  13. }
  14. Arrays.sort(a);
  15. // Collections.sort(a,reverseOrder());
  16. for(int i:a){
  17. System.out.print(i+" ");
  18. }
  19. sc.close();
  20. }
  21. }
Success #stdin #stdout 0.13s 56988KB
stdin
5
4 1 5 3 2
stdout
1 2 3 4 5