Hi, I need the ability to sort a collection of customers which contains a property of numeric string.
How Can I sort the below collection by code in numeric order. Again Code is a string.
class Program
{
static void Main(string[] args)
{
SortableObservableCollection<Customer> customerList = new SortableObservableCollection<Customer>();
customerList.Add(new Customer() {Name = "Jo", Code = "1"});
customerList.Add(new Customer() { Name = "Jo", Code = "10" });
customerList.Add(new Customer() { Name = "Jo", Code = "11" });
customerList.Add(new Customer() { Name = "Jo", Code = "9" });
customerList.Add(new Customer() { Name = "Jo", Code = "7" });
customerList.Add(new Customer() { Name = "Jo", Code = "12" });
customerList.Add(new Customer() { Name = "Jo", Code = "13" });
customerList.Add(new Customer() { Name = "Jo", Code = "2" });
customerList.Add(new Customer() { Name = "Jo", Code = "5" });
customerList.Add(new Customer() { Name = "Jo", Code = "7" });
//Order them by Code How
}
}
public class Customer
{
public string Name { get; set; }
public string Code { get; set; }
}
Thanks for any suggestions