bubble sort and foreach index
<p>I have some code below for a button click event, 
which uses bubble sort. I am a little bit unclear 
of the use. Trying to sort an array in ascending 
order. Also I have to use a foreach and need to 
get an index from it some how. 
An attempt int z = a.GetEnumerator(); does not work. int k = 0;//Cheat to get code working</p>

<pre><code>        int k = 0;//Cheat to get code working
        foreach (BankAccount BankAccount in a)
        //for (int i = 0; i &lt; a.Length; i++)
        {
            //int z = a.GetEnumerator();
            lstBefore.Items.Add(a[k].show());
            k += 1;//Cheat to get code working
        }
        //if (a[0] is IComparable)
        //{
            //Sort.BubbleSort(a);//Sort a
            k = 0;//Cheat to get code working
            for (int i = 0; i &lt; a.Length; i++)
            {
                lstAfter.Items.Add(a[k].show());
                //else MessageBox.Show("unable to sort");
                k += 1;//Cheat to get code working
            }
        //}
        //else MessageBox.Show("unable to sort");

class Sort : IComparable
{
    public static void BubbleSort(IComparable[] arr)
    {
        bool swap = true;
        IComparable temp;
        for (int i = 0; swap; i++)
        {
            swap = false;
            for (int j = 0; j &lt; (arr.Length - (i + 1)); j++)
            {
                //int test = arr[j].CompareTo(arr[j + 1]);                    
                if (arr[j].CompareTo(arr[j + 1]) &gt; 0)
                //If this balance is &lt; than next balance                    
                {
                    temp = (IComparable)arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                    swap = true;
                }
            }
        }
    }
}
</code></pre>

<p>Also I have</p>

<pre><code>public class BankAccount : IComparable, IComparable&lt;BankAccount&gt;//Class BackAccount -             //Icomarable    
{
    private decimal balance;
    private string FullName;
    //...

    public int CompareTo(BankAccount that)//Compare To        
    {
        if (this.balance &gt; that.balance) return -1;//If this balance is &gt; than next balance            
        if (this.balance == that.balance) return 0;//If this balance is = to next balance            
        return 1;//If this balance is &lt; than next balance            
        //return this.balance.CompareTo(that.balance);        
    }
}
Thanks,
</code></pre>
