I have created a insert function which inserts the item in the template array, the position of the item in the array template list is depending on the ratio of wins over total games played, I have manged to work out the insertion sort if the two scores of a team are not equal and sort them properly, however I needs to handle if the scores are equal to decide who standing is higher by total points I have overloaded the < >=
=
==
operators already so I am at lost at how to handle this
Here is the insert function
template<class elemType>
void arrayListTypeT<elemType>::insert(elemType insertItem)
{
// Your code to insert a new item into the list goes here.
// You are required to check for the following errors:
// Duplicate insertion.
// Full list.
// If either error occurs, display an appropriate message leave the
// list unchanged.
int i = seqSearch(insertItem);
if(isFull())
cout<<"List is full, no items can be inserted\n"<<endl;
else if(i >= 0)
cout<<"Duplicate record found in file\n"<<endl;
else
{
list[length] = insertItem;
length++;
int i,j;
elemType temp;
for(i=0;i<length;i++)
{
for(j=0;j<i;j++)
{
if(list[i]>=list[j] list[i] = list[j])
{
temp = list[i]; //swap
list[i] = list[j];
list[j] = temp;
}
}
}
}