Guest User

Untitled

a guest
Nov 18th, 2016
659
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace CustomComparator_2
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] numbersArray = Console.ReadLine().Split().Select(int.Parse).ToArray();
  14.  
  15.             Array.Sort(numbersArray,
  16.                 (x, y) =>
  17.              {
  18.                  int reminderX = Math.Abs(x % 2);
  19.                  int reminderY = Math.Abs(y % 2);
  20.                  return reminderX.CompareTo(reminderY);
  21.              });
  22.  
  23.             Console.WriteLine(string.Join(" ", numbersArray));
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment