Sorting

Better Bubble Sort

better - but still not great
/**
Bubble_Sort: procedure
  parameter
    array: 1-d array of integer in out
    low, high : in only integer
  variable
    i, j : integer
**/

void better_bubble_sort(float array[], int low, int high)
{
  int i = low, j, sorted = 0;   
  int count = 1;
  float temp;

  while ((sorted == 0) && (i <= high))
  {
     sorted = 1;
     for (j = low; j <= high - count; j++)
     {
       if (array[j] > array[j+1])
       {
          swap(&array[j], &array[j+1])
          sorted = 0;
       }
     }
     i = i + 1;
     count = count + 1;
  }
}