Question: I have class like:

```
class SortNode
{
    public Int32 m_valRating = 0;

    public SortNode(Int32 valRating)
    {
        this.m_valRating = valRating;
    }
}

```

and some list `refSortNodeList`:

```
List<SortNode> refSortNodeList = new List<SortNode>();

Random refRandom = new Random();

for (int i = 0; i < 100; ++i)
{
    refSortNodeList.Add(new SortNode(refRandom.Next(-10, 30)));
}

foreach (var varSortNode in refSortNodeList)
{
    Console.WriteLine("SortNode rating is {0}", varSortNode.m_valRating);
}

```

How to sort easily my `refSortNodeList` by `m_valRating` field? Or maybe I need to use some another `List` class?

Answer: 
Try this:

```
refSortNodeList.Sort(new delgate(SortNode x, SortNode y)
   {
       return x.CompareTo(y);
    }
);

```
```
List<SortNode> refSortNodeList = new List<SortNode> ();

Random refRandom = new Random ();

for (int i = 0; i < 100; ++i) {
    refSortNodeList.Add (new SortNode (refRandom.Next (-10, 30)));
}

// Use this (Linq) if you're using .NET 3.5 or above.
var sortedList = refSortNodeList.OrderBy (node => node.m_valRating);
foreach (var varSortNode in sortedList) {
    Console.WriteLine ("SortNode rating is {0}", varSortNode.m_valRating);
}

// Use this otherwise (e.g. .NET 2.0)
refSortNodeList.Sort (
    delegate (SortNode n1, SortNode n2) {
        return n1.m_valRating.CompareTo (n2.m_valRating);
    }
);

foreach (var varSortNode in refSortNodeList) {
    Console.WriteLine ("SortNode rating is {0}", varSortNode.m_valRating);
}

```