sort1.cc From Astrachan, pp 529 ------------------------------- int MinIndex(Vector & a, int first, int last) // precondition: 0 <= first, first <= last, a[first]...a[last] are initialized // postcondition: returns index of smallest entry in a between first // and last inclusive { } void Swap(int & a, int & b) // postcondition: swap a and b { int temp = a; a = b; b = temp; } void Sort(Vector & a, int numElts) // precondition: a contains numElts ints // postcondition: elements of a are sorted in non-decreasing order { int k; int index; for(k=0; k < numElts - 1; k+=1) { index = MinIndex(a,k,numElts - 1); // find smallest from k to end Swap(a[k],a[index]); } }