Hey....I face some problem in counting the repeated times of items...hope somebody can helps me..

For example:
I have a list of data that store in string array

1
2
1
2
3
1
2
3
2
2
3
4
2
4
5
2
3
.........

(maybe have different numbers)
now i wan to count each item repeated times

item        values
1               3
2               5
3               4
4               2
5               1

after that, i need to sort them based on the values from highest to lowest.

item        values
2                5
3                4
1                3
4                2
5                1

this is the output that i expected.Hope someone will help me..thanks ya.
here is my coding:

                    String[] sArray = new String[showFile1.Lines.Length];
                    int p = 0;
                    foreach (String k in listItem.Keys)
                    {
                        sArray[p] = k;
                        show += sArray[p]+"\n";                          
                        p++;
                    } //MessageBox.Show(show.ToString());

                    KeyItems1 = show.Split(' ');
                    String display = "";
                    ArrayList list = new ArrayList();
                    foreach (string h in KeyItems1)
                    {
                        display += h + "\n"; 

                    }
                    list.Add(display);                     
                    String display2 = "";
                    foreach (string i in list)
                    {
                        display2 += i ;
                    } 
                    //MessageBox.Show(display2.ToString());

                    String[] sArray2 = list.ToArray(typeof(String)) as String[];
                    String display3 = "";
                    foreach (String value in sArray2)
                    {
                        display3 += value;
                    }

Mate, if this is not you final version of the project, I wont even help you out.
That it wont be like last time, when I did the code for you (school homework I guess), and then you came out later to ungrade it.
No, cant do.

So, what is it gonna be?
Is this it, or not?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.