Run ❯
Get your
own C#
server
❯
Run Code
Ctrl+Alt+R
Change Orientation
Ctrl+Alt+O
Change Theme
Ctrl+Alt+D
Change Language
Go to Spaces
Ctrl+Alt+P
using System; using System.Collections.Generic; using System.Linq; namespace MyApplication { class Program { static void Main(string[] args) { List
cars = new List
{ "Volvo", "BMW", "Ford", "Mazda" }; var sorted = cars.OrderBy(c => c); Console.WriteLine(string.Join(", ", sorted)); // BMW, Ford, Mazda, Volvo List
scores = new List
{ 45, 80, 62, 30, 95 }; var highFirst = scores.OrderByDescending(s => s); Console.WriteLine(string.Join(", ", highFirst)); // 95, 80, 62, 45, 30 } } }
BMW, Ford, Mazda, Volvo
95, 80, 62, 45, 30