I have a list of a class like this :
public class CityCodeInfo
{
public string CityName;
public string Province;
public string Code;
}
List<CityCodeInfo> lstCityt = new List<CityCodeInfo>();
How can i sort this list by any of its variables (cityname, province and code)
i’ve tried this code:
lstCityt.Sort((x, y) => string.Compare(x.CityName, y.CityName));
but it doesn’t work…
Any Idea?!
You can use LINQ for it.
Ascending Order
Descending Order
Both