// File: sort-parts.cc
// test template-ized bubble sort function

#include <iostream>
using namespace std;

#include "part.h"

template <class T >
void bubble_sort( T [],  int );

int main() {
   const int MaxSize = 100;
   Parts List[MaxSize];
   Get_Inventory( List, MaxSize, NParts );

   bubble_sort( List, Nparts );

}

// Bubble sort - template version
template <class T>
void bubble_sort( T x[], const int n ) {
	int pass = 0, k, switches;
	T temp;

	switches = 1;

	while( switches ) {
	    switches = 0;
	    pass++;
	    for( k = 0; k < n - pass; k++ ) {
		if( x[k] > x[k+1] ) {
		    temp = x[k];
		    x[k] = x[k+1];
		    x[k+1] = temp;
		    switches = 1;
		}
	    }
	}

	return;
}
