2
I have an object of the type Ata
where I own the property NroAta
which corresponds to the number of the minutes in question, but in grid when I 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 method OrderBy
.
You are not sorting numbers, you are sorting strings(text)
– ramaral