Thanks Dave for your answer,
I still wonder how i can sort the list based on the comparison of "a"
values
I mean
private bool comp(A aref, A bref)
{
return aref.a<bref.a;
}
if i put this function in a icomparable, implementation may become
complex,
built-in sort of List can't do this, can it ? How can I make a sort()
then ?
Hi Deniel,
here is an example of how you can sort the contents of your list using an
anonymous delegate, which makes it very simple to sort the items in the list:
class Person
{
private string name;
public Person(string name)
{
this.name = name;
}
public string Name
{
get
{
return this.name;
}
}
}
static void Main(string[] args)
{
List<Person> people = new List<Person>();
Person mark = new Person("mark");
Person bob = new Person("bob");
Person frank = new Person("frank");
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.