// sortArray01.cc  P. Conrad for CISC220 06J

#include "selectionSort.h"

#include <iostream>
using namespace std;

#include <cassert>

int findPositionOfMax(int a[], int size)
{
  int positionOfMax = 0;
  for (int i=1; i<size; i++)
    {
      if (a[positionOfMax] < a[i] )
	positionOfMax = i;
    }
  return positionOfMax;
}

void swap(int a[], int i, int j)
{
  int temp = a[i];
  a[i] = a[j];
  a[j] = temp;
}


void sortArray(int a[], int n)
{

  for (int i=n; i>0; i--)
    {
      int j = findPositionOfMax(a,i);
      swap(a,j,i-1);
    }

  return;

}

