This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
You have to use ... Sorting algos ... like insert sort, merge ..etc I am giving you the code for Insert Sort Ok !! int temp ; for( int j = 1; j<aa.length ; j++)> { for( int i = 0; i<j ; i++)> { temp = aa[i]; aa[i] = aa[j]; aa[j] = temp; } }
Originally posted by Khurram Akhter: I made an array int []aa = { 1,5,2,6,7,9,8} I want to sort this array with the help of for loop, so what should i do now....
There are two methods of sorting . 1 Bubble sorting 2 Internal sorting Following is the procedure of internal sortting int i=0,j=0,temp=0; for(i=0 ; i < aa.length() ; i++){ for(j=i+1; j<=aa.length() ;j++){ if(aa[i] > aa[j]){ temp=aa[i]; aa[i] = aa[j]; aa[j] = temp; } } } Note : Not sure aboout the method of aa.length() or aa.length