Hi ,
Check this i believe this what you want
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog dialogu = new OpenFileDialog();
dialogu.Filter = "*.txt|*.txt";
if (dialogu.ShowDialog() == DialogResult.OK)
{
string[] all = File.ReadAllLines(dialogu.FileName, System.Text.Encoding.Default);
listBox1.DataSource = all;
all.ToList();
Dictionary<string,int> dict = new Dictionary<string,int>();
foreach (string item in all)
{
int len = item.IndexOf("[");
int len2 = item.IndexOf("]");
string itm = item.Remove(0, len+1); ;
string key1 = item.Substring(0, len);
string value1 = itm.Substring(0, itm.Length-1);
dict.Add(key1,Convert.ToInt32( value1));
}
var res = (from x in dict
orderby x.Value descending
select x).ToList();
listBox1.DataSource = null;
listBox1.DataSource = res;
}
}
Best Regards
M.Mitwalli