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;
}