I have a delimited text file:
Steve,12,33
Tim,34,28
Mark,22,37
Tom,21,30
Cliff,13,33
Vini,17,28
Matt,10,28
Ben,9,29
Brandon,15,14
I need to sort this in ascending order by the second column. It works except I get this:
Matt 10 28
Steve 12 33
Cliff 13 33
Brandon 15 14
Vini 17 28
Tom 21 30
Mark 22 37
Tim 34 28
Ben 9 29
If I put a 0 in front of the 9 it will sort, properly. If not as you can see, it goes to the bottom of the list. Can't figure out why. Here is the code:
private void btnResults_Click(object sender, EventArgs e)
{
try
{
string strFileName = this.txtPath.Text;
var qry = from line in File.ReadAllLines("C:\\Users\\Bomac\\Desktop\\TestAge.txt")
let runner = line.Split(',')
orderby runner[1] ascending
select new Runner()
{
Name = runner[0],
Time = runner[1],
Age = runner[2]
};
foreach (var item in qry)
{
this.txtOutPut.AppendText((item.Name) + " " + (item.Time) + " " + (item.Age) + Environment.NewLine);
}
}
catch
{
}
finally
{
}
}
Any help would be greatly appreciated.
Steve,12,33
Tim,34,28
Mark,22,37
Tom,21,30
Cliff,13,33
Vini,17,28
Matt,10,28
Ben,9,29
Brandon,15,14
I need to sort this in ascending order by the second column. It works except I get this:
Matt 10 28
Steve 12 33
Cliff 13 33
Brandon 15 14
Vini 17 28
Tom 21 30
Mark 22 37
Tim 34 28
Ben 9 29
If I put a 0 in front of the 9 it will sort, properly. If not as you can see, it goes to the bottom of the list. Can't figure out why. Here is the code:
private void btnResults_Click(object sender, EventArgs e)
{
try
{
string strFileName = this.txtPath.Text;
var qry = from line in File.ReadAllLines("C:\\Users\\Bomac\\Desktop\\TestAge.txt")
let runner = line.Split(',')
orderby runner[1] ascending
select new Runner()
{
Name = runner[0],
Time = runner[1],
Age = runner[2]
};
foreach (var item in qry)
{
this.txtOutPut.AppendText((item.Name) + " " + (item.Time) + " " + (item.Age) + Environment.NewLine);
}
}
catch
{
}
finally
{
}
}
Any help would be greatly appreciated.