12345678910
for (int i=0; i<n; i++) //insertion sort, ar[n], sort in decreasing order { int index =i; for (int j=i+1; j<n; j++) { if (ar[index]<ar[j]) index =j; } swap (ar[i], ar[index]); }