fork download
  1. class Ideone {
  2. static void main(String[] args) {
  3. def a = [9, 4, 5, 8, 9, 7, 4, 2, 3] ;
  4. def temp=0;
  5.  
  6. for(int i =0; i <a.size(); i=i+3)
  7. {
  8.  
  9. for(int k=0; k<2;k++)
  10. {
  11. for(int j=i;j<i+2;j++)
  12. {
  13. // print a
  14. if(a[j]>a[j+1])
  15. {
  16. temp=a[j];
  17. a[j]=a[j+1];
  18. a[j+1]=temp;
  19.  
  20. }
  21. }
  22. }
  23. }
  24. print a
  25. }
  26. }
  27.  
Success #stdin #stdout 0.94s 84804KB
stdin
Standard input is empty
stdout
[4, 5, 9, 7, 8, 9, 2, 3, 4]