Advertisement
Guest User

Sort of sorting

a guest
Mar 26th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. class Program
  6. {
  7.     static void Main(string[] args)
  8.     {
  9.         string line = "";
  10.         bool first = true;
  11.         while ((line = Console.ReadLine()) != "0")
  12.         {                                
  13.             int n = int.Parse(line);
  14.             List<string> Print = new List<string>();
  15.             for (int i = 0; i < n; i++)
  16.             {
  17.                 Print.Add(Console.ReadLine());
  18.             };
  19.            
  20.             var sorted = Print.OrderBy(x => x.Remove(Math.Min(x.Length, 2)));
  21.             if (!first)
  22.             {
  23.                 Console.WriteLine();
  24.             }
  25.             first = false;
  26.             foreach (string name in sorted)
  27.             {
  28.                 Console.WriteLine(name);
  29.             }
  30.  
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement