In my application I download some data from website providing landscape informations like population, landscape area and few more.
After parsing html code, data are stored in list of objects
public class Landscape
{
public int Population { get; set; }
public string Area { get; set; }
}
public List<Landscape> data;
No problem with that. Follows filling dataGrid and that’s purpose of my application. Now, where is the problem? Area info on the website is in semi-numeric, semi-string format. For example: 10 000 km2.
I have possibility to choose whether to trim km2 suffix and store data as int, or do nothing about it and store data as string. Since I want have data in dataGrid in original format, I decided not to trim.
Finally, is there a way to order rows (by size of area) as int although it is string type?
You can use linq to sort by the translated value but don’t think this will be fast.
I think a better way would be to save the Area as a number and add the trimmed part just for output.