0

```
//sort the items of an array using straight insertion sort
//
static void StraightInsertionSort(int[] listtosort)
{
int element;
int ic;
//index of element to be compared, index starts at 0
for (int loopvar = 1; loopvar < listtosort.Length; loopvar++) //loop trough each element in turn
{
element = listtosort[loopvar];
ic = loopvar-1;
while (ic >= 0 && listtosort[ic] > element )
{
listtosort[ic + 1] = listtosort[ic]; //move all elements
ic--;
}
listtosort[ic + 1] = element; //Insert element
}
}
// sort the items of an array using bubble sort
//
public static void BubbleSort( int[] ar )
{
for ( int pass = 1; pass < ar.Length; pass++ )
for ( int i = 0; i < ar.Length - 1; i++ )
if ( ar[ i ] > ar[ i + 1 ] )
Swap( ar, i );
}
// swap two items of an array
//
public static void Swap( int[] ar, int first )
{
int hold;
hold = ar[ first ];
ar[ first ] = ar[ first + 1 ];
ar[ first + 1 ] = hold;
}
```