Home > DeveloperSection > Blogs > C# Sort List Method

C# Sort List Method


C# C# 
Ratings:
0 Comment(s)
 3042  View(s)
Rate this:
This C# example shows how to sort elements in a List.
Sample Program that uses Sort [C#]

using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
    List<string> list = new List<string>();
    list.Add("Dog");
    list.Add("BAT");
    list.Add("AGE");

    // Sort alphabetically, in ascending order (A - Z)
    list.Sort();

    foreach (string value in list)
    {
        Console.WriteLine(value);
    }
    }
}

Output

AGE
BAT
DOG

Don't want to miss updates? Please click the below button!

Follow MindStick