I have an object of type Ata
where I have the property NroAta
that corresponds to the number of the Minutes in question, but in the grid when I will sort by this number, it ends up putting the numbers in the wrong order. Ex.:
1, 10, 12, 2, 23, 3 ... and so it goes.
I created a pseudo code of what I'm using to use as an example:
List<Ata> lstAtas = new List<Ata>()
{
new Ata{ NroAta = "1"},
new Ata{ NroAta = "10"},
new Ata{ NroAta = "6"},
new Ata{ NroAta = "4"},
new Ata{ NroAta = "5"},
new Ata{ NroAta = "2"},
new Ata{ NroAta = "3"},
};
lstAtas = lstAtas.OrderBy(x => x.NroAta).ToList();
foreach (var ata in lstAtas)
{
Console.WriteLine("{0}", ata.NroAta);
}
In the example, I need the numbers to be in the correct order: 1, 2, 3, 4, 5, 6, 10 using the OrderBy
method.