C# How to sort string of objects by string value : <p>I have list of objects with different values int's, double's, string's.
In this case i want to sort list of objects by "name".
I done it for int's but can't by string.</p>

<p>,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,</p>

<pre><code>public void CreateMammal()                             // obj creating method
    {        
        Console.WriteLine("Podaj Imie: ");
        name = Console.ReadLine();
        Console.WriteLine("Podaj Wiek: ");
        age = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Podaj Wagę: ");
        weigth = Convert.ToDouble(Console.ReadLine());
        Console.WriteLine("Podaj Kolor Futra: ");
        furColour = Console.ReadLine();
        ToString();                    
     }
.
.
.
List&lt;Animal&gt; animals = new List&lt;Animal&gt;();     // list declaration
.
.
.
Mammal mammal = new Mammal();
mammal.CreateMammal();
Console.WriteLine("\n\nTwoj ssak:\n" + 
mammal.ToString());
animals.Add(mammal);
.
.
.

//animals.Sort((x, y) =&gt; x."name" - y."name");  // algorytm sortowania
//printAnimals(animals);

animals.Sort();                   // here we go with problem

foreach (string value in animals)
{
Console.WriteLine(value);
}
.
.
.
 public static void printAnimals(List&lt;Animal&gt; animals) 
    {
        foreach (var animal in animals)
        {
            Console.WriteLine(animal.ToString());
        }
    }
</code></pre>
