Advertisement
j0k3r

core2

Jan 12th, 2013
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ConsoleApplication4
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             var somethings = new List<Something>
  12.             {
  13.                 new Something(1,2,3),
  14.                 new Something(2,8,5),
  15.                 new Something(1,1,4),
  16.                 new Something(4,3,5),    
  17.                 new Something(2,6,3),
  18.                 new Something(2,2,5),
  19.                 new Something(1,3,5),
  20.                 new Something(3,2,2),
  21.                 new Something(3,7,4),
  22.             };
  23.  
  24.             var q = somethings.GroupBy(g => g.A).OrderBy(g => g.Key).SelectMany(g => g.OrderBy(x => x.B));
  25.  
  26.             foreach (var item in q)
  27.             {
  28.                 Console.WriteLine("{0} {1} {2}", item.A, item.B, item.C);
  29.             }
  30.  
  31.             Console.ReadLine();
  32.         }
  33.     }
  34.  
  35.     class Something
  36.     {
  37.         public int A { get; set; }
  38.         public int B { get; set; }
  39.         public int C { get; set; }
  40.  
  41.         public Something(int a, int b, int c)
  42.         {
  43.             A = a;
  44.             B = b;
  45.             C = c;
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement