gabi11

Functional Programming - 08. Custom Comparator

May 29th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6.  
  7. namespace Advanced
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Func<IEnumerable<int>, IEnumerable<int>> sort = x => x.Where(n => n % 2 == 0)
  14.             .OrderBy(n => n)
  15.             .Concat(x.Where(m => m % 2 != 0)
  16.             .OrderBy(m => m));
  17.  
  18.             Console.WriteLine(string.Join(" ", sort(Console.ReadLine()
  19.                                                     .Split()
  20.                                                     .Select(int.Parse))));
  21.         }
  22.     }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment