Heapsort Code (2)
void adjust(int Top, int Last)
    {
    float TopVal = array[Top];                  // Set aside top of heap
    int Parent, Child;

    for( Parent = Top; ; Parent = Child )       // Iterate down through tree
      {
      Child = 2*Parent+1;                       // Child means left child

      if( Child > Last )
        break;                                  // Left child non-existent

      if( Child+1 <= Last                       // Right child exists
           && array[Child] < array[Child+1] )   // and right child is larger
        Child++;                                // Child is the larger child

      if( TopVal >= array[Child] )
        break;                                  // Location for TopVal found

      array[Parent] = array[Child];             // Move larger child up in tree
      }

    array[Parent] = TopVal;                     // Install TopVal in place
    }