problem with sorting array

ZileZile United States
edited June 2014 in Assembler Developer

Hi I am new on this forum and also just started with c#, I am trying to write some program where you have dynamically allocated buttons stored in an array and every time u click on a button it show you number of a button in a label. also I needed to update the frequency of clicked buttons and at the end to sort them from smallest to largest buy clicking on one button. So I cant use sort method I only can use nested for loops.
This is my code so far and every time I click on button for sorting it gives me only one number??
Thank you

lstNum is a number of allocated buttons and freqArray is an array of buttons, and lbl.Out.Digits is label where number of clicked button appear and there I need to display sorted list of clicked buttons.

    int temp = 0;
                for (int i = 0; i < lastNum; i++)
                        for (int j = i + 1; j < lastNum; j++)
                            if (freqArray[i] > freqArray[j])
                                temp = freqArray[i];
                                freqArray[i] = freqArray[j];
                                freqArray[j] = temp;


                        lblOutDigits.Text =  freqArray[i].ToString();
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!