Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace CustomComparator
- {
- public class MyComparer : IComparer<int>
- {
- public int Compare(int x, int y)
- {
- return x % 2 == y % 2 ? 0 : x % 2 == 0 ? -1 : 1;
- }
- }
- public class StartUp
- {
- public static void Main(string[] args)
- {
- var numbers = Console.ReadLine().Split(new[] {' ', '\t'}, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse).OrderBy(p=>p).ToArray();
- Array.Sort(numbers,new MyComparer());
- Console.WriteLine(string.Join(" ",numbers));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement