Ejemplo n.º 1
0
	static void Main()
	{
		var students = new[] 
		{
			               new { FirstName = "Pesho", LastName = "Peshev" },
			               new { FirstName = "Gosho", LastName = "Goshev" },
			               new { FirstName = "Ivan", LastName = "Ivanov" },
			               new { FirstName = "Dobromir", LastName = "Enchev" },
			               new { FirstName = "Svetozar", LastName = "Penov" }
		};

		var firstSort = students.OrderByDescending(st => st.FirstName)
								.ThenByDescending(st => st.LastName);

		Console.WriteLine("1. Using LINQ extension method:");
		Console.WriteLine(new string('=', 50));
		Console.WriteLine(string.Join(Environment.NewLine, firstSort));
		Console.WriteLine();

		var secondSort =
			from student in students
			orderby student.FirstName descending, student.LastName descending
			select student;

		Console.WriteLine("2. Using LINQ query:");
		Console.WriteLine(new string('=', 50));
		Console.WriteLine(string.Join(Environment.NewLine, secondSort));
	}
Ejemplo n.º 2
0
    static void Main(string[] args)
    {
        var students = new[]
        {
            new {FirstName = "Vasil", LastName = "Levski", Age = 23},
            new {FirstName = "Hristo", LastName = "Smirnenski", Age = 21},
            new {FirstName = "Ivan", LastName = "Vazov", Age = 40},
            new {FirstName = "Hristo", LastName = "Botev", Age = 35},
            new {FirstName = "Delio", LastName = "Voivoda", Age = 28},
        };

        Console.WriteLine("\n Unsorted students: \n");
        foreach (var student in students)
        {
            Console.WriteLine("{0} {1} {2}", student.FirstName, student.LastName, student.Age);
        }

        Console.WriteLine("\n Sorted DESCENDING with Lambda: \n");
        var sortedWithLambda = students.OrderByDescending(student => student.FirstName).ThenByDescending(student => student.LastName);
        foreach (var student in sortedWithLambda)
        {
            Console.WriteLine("{0} {1} {2}", student.FirstName, student.LastName, student.Age);
        }

        Console.WriteLine("\n Sorted DESCENDING with LINQ queries: \n");
        var sortedWithLINQ =
            from student in students
            orderby student.FirstName descending, student.LastName descending
            select student;

        foreach (var student in sortedWithLINQ)
        {
            Console.WriteLine("{0} {1} {2}", student.FirstName, student.LastName, student.Age);
        }
    }
Ejemplo n.º 3
0
    static void Main()
    {
        var students = new[] { new { FirstName = "Pesho", LastName = "Ivanov", Age=19 },
            new { FirstName = "Assen", LastName = "Georgiev", Age=25 }, new { FirstName = "Ivanka", LastName = "Tsoneva", Age=36 },
        new { FirstName = "Gogo", LastName = "Asenov", Age=22 },new { FirstName = "Niki", LastName = "Kostov", Age=21 },
        new { FirstName = "Ivanka", LastName = "Asenova", Age=21 }};

        var sortedStudentsLambda = students.OrderByDescending(student => student.FirstName).ThenByDescending(student=>student.LastName);

        Console.WriteLine(new string('-', 50));
        Console.WriteLine("The students sorted with lambda expressions are:");
        Console.WriteLine(new string('-', 50));

        foreach (var student in sortedStudentsLambda)
        {
            Console.WriteLine("First Name: {0,-10} Last Name: {1,-10} Age: {2,-10}", student.FirstName, student.LastName, student.Age);
        }

        Console.WriteLine(new string('-',50));
        var sortedStudentsLINQ = from student in students
                                 orderby student.FirstName descending, student.LastName descending
                                 select student;
        Console.WriteLine("The students sorted with LINQ are:");
        Console.WriteLine(new string('-', 50));
        foreach (var student in sortedStudentsLINQ)
        {
            Console.WriteLine("First Name: {0,-10} Last Name: {1,-10} Age: {2,-10}", student.FirstName, student.LastName, student.Age);
        }
    }
Ejemplo n.º 4
0
    static void Main()
    {
        var students = new[]
        {
            new { FirstName = "Cvetelina", LastName = "Dimitrova" },
            new { FirstName = "Angel", LastName = "Borisov" },
            new { FirstName = "Dimityr", LastName = "Cvetkov" },
            new { FirstName = "Boris", LastName = "Angelov" },
            new { FirstName = "Filip", LastName = "Georgiev" }
        };

        // Extension methods
        var orderedStudents = students.OrderByDescending(x => x.FirstName).ThenBy(y => y.LastName);

        Console.WriteLine("#1: Using extension methods: ");
        Console.WriteLine(string.Join(Environment.NewLine, orderedStudents));

        // Linq query
        orderedStudents =
                         from student in students
                         orderby student.FirstName descending, student.LastName descending
                         select student;

        Console.WriteLine("\n#2: Using LINQ: ");
        Console.WriteLine(string.Join(Environment.NewLine, orderedStudents));
    }
        static void Main(string[] args)
        {
            // Lambda
            var arr = new[]{
                new Student { Fname = "Petar", Lname = "Petrov" },new Student { Fname = "Ivo", Lname = "Andonov" },
                new Student { Fname = "Petar", Lname = "Zeshev" },new Student { Fname = "Zahari", Lname = "Baxarov" }
            };

            var sorted = arr.OrderByDescending(a => a.Fname).ThenByDescending(b => b.Lname);
            foreach (var item in sorted)
            {
                Console.WriteLine("{0} {1}", item.Fname, item.Lname);
            }

            Console.WriteLine("---------------------------------------------------");
            // Linq
            var linqSorted =
                            from name in arr
                            orderby name.Fname, name.Lname
                            select name;

            foreach (var item in sorted)
            {
                Console.WriteLine("{0} {1}", item.Fname, item.Lname);
            }
        }
    static void Main()
    {
        var students = new[] {
        new {FirstName = "Petar", LastName = "Georgiev", Age = 19},
        new {FirstName = "Dimo", LastName = "Petrov", Age = 29},
        new {FirstName = "Ivan", LastName = "Mihov", Age = 22},
        new {FirstName = "Pavel", LastName = "Zafirof", Age = 21},
        new {FirstName = "Pavel", LastName = "Marinov", Age = 21},
        new {FirstName = "Boris", LastName = "Lubenov", Age = 22},
        new {FirstName = "Georgi", LastName = "Aleksandrov", Age = 23}};

        Console.WriteLine("Ordered using lambda expression: ");

        foreach (var student in students.OrderByDescending(student => student.FirstName).ThenByDescending(student => student.LastName))
        {
            Console.WriteLine("{0} {1}", student.FirstName, student.LastName);
        }

        Console.WriteLine();
        Console.WriteLine("Ordered using LINQ: ");
        var selectedWithLINQ =
            from student in students
            orderby student.FirstName descending, student.LastName descending
            select student;

        foreach (var student in selectedWithLINQ)
        {
            Console.WriteLine("{0} {1}", student.FirstName, student.LastName);
        }
    }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            var students = new[]
            {
                new {firstName ="Ivan", lastName = "Jorgov",age = 23},
                 new {firstName ="Ivan", lastName = "Ivanov",age = 24},
                new {firstName ="Boris", lastName = "Dobrev",age = 19},
                new {firstName ="Pesho", lastName = "Ivanov",age = 26},
                new {firstName ="John", lastName = "Atanasov",age = 33},
                new {firstName ="Steve", lastName = "Jobs",age = 37},
                new {firstName ="Krasimir", lastName = "Stefanov",age = 20},
                 new {firstName ="Ivan", lastName = "Berov",age = 20},
                new {firstName ="Miro", lastName = "Stavrev",age = 18}
            };
            var lamdaStudents = students.OrderByDescending(student => student.firstName).ThenByDescending(student => student.lastName);

            foreach (var student in lamdaStudents)
            {
                Console.WriteLine("Lamda expression: {0} {1}",student.firstName,student.lastName);
            }

            Console.WriteLine();
            var allStudents =
                from student in students
                orderby student.firstName descending, student.lastName descending
                select student;
            foreach (var student in allStudents)
            {
                Console.WriteLine("Linq : {0} {1} ", student.firstName, student.lastName);
            }
        }
Ejemplo n.º 8
0
        public void iquerable_should_be_sorted_correctly()
        {
            var now = DateTime.Now;

            var source = new[]
            {
                new DummyDocument
                {
                    Name = "Middle",
                    CreatedAt = now
                },
                new DummyDocument
                {
                    Name = "Last",
                    CreatedAt = now.AddHours(1)
                },
                new DummyDocument
                {
                    Name = "First",
                    CreatedAt = now.AddHours(-1)
                }
            }
            .AsQueryable();

            var sortedData = source.DynamicOrderBy(
                new OrderByRequest(
                    propertyName: "createdAt",
                    direction: OrderByDirection.Descending));
            var expectedSortedData = source.OrderByDescending(document => document.CreatedAt);

            sortedData.SequenceEqual(expectedSortedData).Should().BeTrue();
        }
Ejemplo n.º 9
0
 static void Main(string[] args)
 {
     var names = new[]{
      new{First="Anton",Second="Petleshjov"},
      new{First="Gabriela",Second="Gincheva"},
      new{First="Vladimir",Second="Petrov"},
      new{First="Gresha",Second="Stoilov"},
      new{First="Shterev",Second="Qnislavov"},
      new{First="Anna",Second="Hezmakian"},
      new{First="Huang",Second="Hu"},
      new{First="Borislav",Second="Nakov"},
      };
     //lambda expresions
     var students =
     names.OrderByDescending(a => a.First)
      .ThenByDescending(a => a.Second);
     //Linq
     //         var students =
     //from n in names
     //orderby n.First descending, n.Second descending
     //select n; 
     foreach (var name in students)
     {
         Console.WriteLine(name.First + " " + name.Second);
     }
 }
Ejemplo n.º 10
0
    static void Main()
    {
        var students = new[]
            {
                new { FirstName = "Ivan", LastName = "Mihailov"},
                new { FirstName = "Kiril", LastName = "Ivanov"},
                new { FirstName = "Asen", LastName = "Dimitrov"},
                new { FirstName = "Pavel", LastName = "Stoianov"}
            };

        //With Lambda
        Console.WriteLine("Order with Lambda");
        var orderByNameLambda = students.OrderByDescending(x => x.FirstName).ThenByDescending(x => x.LastName);

        foreach (var student in orderByNameLambda)
        {
            Console.WriteLine("{0} {1}", student.FirstName, student.LastName);
        }

        Console.WriteLine();
        //With LINQ
        Console.WriteLine("Order with LINQ");
        var orderByNameLINQ =
            from names in students
            orderby names.FirstName descending
            orderby names.LastName descending
            select names;

        foreach (var student in orderByNameLINQ)
        {
            Console.WriteLine("{0} {1}", student.FirstName, student.LastName);
        }
    }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            var studentInfo = new[]
            {
              new  { firstName="Kiril", lastName="Tanushev", Age = 29 },
              new  { firstName="Georgi", lastName="Georgiev", Age = 23 },
              new  { firstName="Angel", lastName="Amneow", Age = 18 },
              new  { firstName="Angel", lastName="Kostadinow", Age = 24 },
               new  { firstName="Foto", lastName="Hoidutin", Age = 21 },
            new  { firstName="GOsho", lastName="Reeretov", Age = 32 }

            };
            var studentsSort =
             from student in studentInfo
             orderby student.firstName, student.lastName        // LINQ
             select student;

            foreach (var item in studentsSort)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine();

            var studentsSortLambda = studentInfo.OrderByDescending(x => x.firstName).ThenByDescending(x => x.lastName);  //Lambda

            foreach (var item in studentsSortLambda)
            {
                Console.WriteLine(item);
            }
        }
        static void Main(string[] args)
        {
            var students = new[]
            {
                new {FirstName = "Atanas", LastName = "Bojilov"},
                new {FirstName = "Kristiqn", LastName = "Atanasov"},
                new {FirstName = "Boian", LastName = "Botev"}
            };

            var orderedNames = students.OrderByDescending( x => x.FirstName).ThenByDescending(x => x.LastName);

            foreach (var item in orderedNames)
            {
                Console.WriteLine(item.ToString());
            }

            var orderedStudents =
                from student in students
                orderby student.FirstName descending, student.LastName descending
                select student;

            foreach (var item in orderedStudents)
            {
                Console.WriteLine(item.ToString());
            }
        }
Ejemplo n.º 13
0
    static void Main()
    {
        var studentList = new[]
        {
            new { firstName = "Atanas", lastName = "Marinov" },
            new { firstName = "Rosen", lastName = "Georgiev" },
            new { firstName = "Spas", lastName = "Stoqnov" },
            new { firstName = "Gurbav", lastName = "Vasilev" },
            new { firstName = "Hristo", lastName = "Smirnenski" }
        };

        var sortedStudentListLambda = studentList.OrderByDescending(student => student.firstName).ThenByDescending(student => student.lastName);

        foreach (var student in sortedStudentListLambda)
        {
            Console.WriteLine(student);
        }

        //LINQ operation
        var sortedStudentListLinq =
            from student in studentList
            orderby student.firstName descending, student.lastName descending
            select student;

        Console.WriteLine();

        foreach (var student in sortedStudentListLinq)
        {
            Console.WriteLine(student);
        }
    }
        public static void Main()
        {
            var students = new[]
            {
                new { firstName = "Marshall", lastName = "Mathers", age = 21 },
                new { firstName = "Earl", lastName = "Simmons", age = 17 },
                new { firstName = "Tupac", lastName = "Shakur", age = 24 },
                new { firstName = "Stanislav", lastName = "Naydenov", age = 18 },
                new { firstName = "William", lastName = "Roberts", age = 25 }
            };

            // Lambda expression:
            var sortedStudents = students
               .OrderByDescending(st => st.firstName)
               .ThenByDescending(st => st.lastName);

            // LINQ query:
            // var sortedStudents =
            //    from st in students
            //    orderby st.FirstName descending, st.LastName descending 
            //    select st;
            foreach (var student in sortedStudents)
            {
                Console.WriteLine("{0} {1}, age: {2}", student.firstName, student.lastName, student.age);
            }
        }
        static void Main()
        {
            var listOfStudents = new[]
            {
                new { FirstName = "Yanis", LastName = "Petkov" },
                new { FirstName = "Mitko", LastName = "Todorov" },
                new { FirstName = "Dinko", LastName = "Bashev" },
                new { FirstName = "Djordjano", LastName = "Ivanov"},
                new { FirstName = "Anatolii", LastName = "Angelov"}
            };

            var result = listOfStudents.OrderByDescending(student => student.FirstName)
                                       .ThenByDescending(student => student.LastName);

            Console.WriteLine("LINQ Extension methods: \n");
            foreach (var student in result)
            {
                Console.WriteLine("{0} {1}", student.FirstName, student.LastName);
            }

            Console.WriteLine("\nLINQ: \n");
            var secondResult = from student in listOfStudents
                               orderby student.FirstName descending, student.LastName descending
                               select student;

            foreach (var item in secondResult)
            {
                Console.WriteLine("{0} {1}", item.FirstName, item.LastName);
            }
        }
Ejemplo n.º 16
0
        static void Main()
        {
            var students = new[] {
            new { FirstName = "Arya", LastName = "Stark", Age = 16 },
            new { FirstName = "Jon", LastName = "Snow", Age = 19 },
            new { FirstName = "Oberyn",  LastName = "Martell", Age = 39 }
        };

            // Exercise 3
            Print(students.Where(student =>
                student.FirstName.CompareTo(student.LastName) < 0
            ));

            // Exercise 4
            Print(students.Where(student =>
                18 < student.Age && student.Age < 24
            ));

            // Exercise 5 Lambda
            Print(students.OrderByDescending(student =>
                student.FirstName
            ).ThenByDescending(student =>
                student.LastName
            ));

            // Exercise 5 - Linq
            Print(
                from student in students

                orderby student.FirstName descending,
                        student.LastName descending

                select student
            );
        }
Ejemplo n.º 17
0
    /// <summary>
    /// Using the extension methods OrderBy() and ThenBy() with lambda 
    /// expressions sort the students by first name and last name in descending order.
    ///Rewrite the same with LINQ.
    /// </summary>
    static void Main()
    {
        var students = new[]
        {
            new { FirstName = "Pesho", LastName = "Peshev"},
            new { FirstName = "Gosho", LastName = "Ivov"},
            new { FirstName = "Ivo", LastName = "Goshev"},
            new { FirstName = "Doncho", LastName = "Ivanov"},
            new { FirstName = "Ivan", LastName = "Donchev"},
            new { FirstName = "Niki", LastName = "Nikov"}
        };

        var firstSortedStudents = students.OrderByDescending(st => st.FirstName)
            .ThenByDescending(st => st.LastName);

        var seconSortedStudents =
            from student in students
            orderby student.FirstName descending, student.LastName descending
            select student;

        Console.WriteLine("LINQ extension method:");
        Console.WriteLine(string.Join(Environment.NewLine, firstSortedStudents));
        Console.WriteLine("LINQ querry:");
        Console.WriteLine(string.Join(Environment.NewLine, seconSortedStudents));
    }
Ejemplo n.º 18
0
        public static Color CalculateColour(double offset)
        {
            var colours = new[]
            {
                new Tuple<double, Color>(0, Color.FromArgb(255, 0, 0, 255)),
                new Tuple<double, Color>(0.5f, Color.FromArgb(255, 0, 255, 0)),
                new Tuple<double, Color>(1, Color.FromArgb(255, 255, 0, 0)),
            };

            Tuple<double, Color> before = colours.OrderBy(c => c.Item1).First();
            Tuple<double, Color> after = colours.OrderByDescending(c => c.Item1).First();

            foreach (var gradientStop in colours)
            {
                if (gradientStop.Item1 < offset && gradientStop.Item1 > before.Item1)
                {
                    before = gradientStop;
                }

                if (gradientStop.Item1 > offset && gradientStop.Item1 < after.Item1)
                {
                    after = gradientStop;
                }
            }

            return Color.FromArgb(
                (byte) (((offset - before.Item1)*(after.Item2.A - before.Item2.A)/(after.Item1 - before.Item1) + before.Item2.A)),
                (byte) (((offset - before.Item1)*(after.Item2.R - before.Item2.R)/(after.Item1 - before.Item1) + before.Item2.R)),
                (byte) (((offset - before.Item1)*(after.Item2.G - before.Item2.G)/(after.Item1 - before.Item1) + before.Item2.G)),
                (byte) (((offset - before.Item1)*(after.Item2.B - before.Item2.B)/(after.Item1 - before.Item1) + before.Item2.B)));
        }
Ejemplo n.º 19
0
    static void Main()
    {
        var students = new[] {
            new { FirstName = "Pesho", LastName = "Ivanov", Age = 17 },
            new { FirstName = "Gosho", LastName = "Petrov", Age = 19 },
            new { FirstName = "Pepi",  LastName = "Ruseva", Age = 25 }
        };

        // Exercise 3
        Print(students.Where(student =>
            student.FirstName.CompareTo(student.LastName) < 0
        ));

        // Exercise 4
        Print(students.Where(student =>
            18 < student.Age && student.Age < 24
        ));

        // Exercise 5A
        Print(students.OrderByDescending(student =>
            student.FirstName
        ).ThenByDescending(student =>
            student.LastName
        ));

        // Exercise 5B
        Print(
            from student in students

            orderby student.FirstName descending,
                    student.LastName descending

            select student
        );
    }
Ejemplo n.º 20
0
		public MyCanvas()
		{
			Width = DefaultWidth;
			Height = DefaultHeight;

			#region Gradient
			for (int i = 0; i < DefaultHeight; i += 4)
			{
				new Rectangle
				{
					Fill = ((uint)(0xff00007F + Convert.ToInt32(128 * i / DefaultHeight))).ToSolidColorBrush(),
					Width = DefaultWidth,
					Height = 4,
				}.MoveTo(0, i).AttachTo(this);
			}
			#endregion


			var _string = new[] { "z", "b", "c", "a" };
			//var _int = new[] { 35, 10, 20, 30, 5 };
			//var _double = new[] { 0.35, 0.1, 0.2, 0.3, 0.05 };

			// jsc:javascript  InitializeArray

			Assert(_string.OrderBy(k => k).First() == "a", "string");
			Assert(_string.OrderByDescending(k => k).First() == "z", "string");
		}
Ejemplo n.º 21
0
 public void OrderByDescending_OrderByDescendingsItems()
 {
     var queryable = new[] { "1", "3", "6", "2", "8" }.AsQueryable();
     var source = new Source<string>(queryable);
     var expected = queryable.OrderByDescending(i => int.Parse(i)).ToList();
     var actual = source.OrderByDescending(i => int.Parse(i)).ToList();
     CollectionAssert.AreEqual(expected, actual);
 }
        public void iquerable_should_be_sorted_correctly()
        {
            var now = DateTime.Now;

            var source = new[]
            {
                new DummyDocument
                {
                    Name = "Middle-2",
                    CreatedAt = now,
                    Count = 1,
                    ComplexType = new DummyPropertyDocument
                    {
                        DummyString = "b"
                    } 
                },
                new DummyDocument
                {
                    Name = "Middle",
                    CreatedAt = now,
                    Count = 10,
                    ComplexType = new DummyPropertyDocument
                    {
                        DummyString = "d"
                    } 
                },
                new DummyDocument
                {
                    Name = "Last",
                    CreatedAt = now.AddHours(1),
                    Count = 20,
                    ComplexType = new DummyPropertyDocument
                    {
                        DummyString = "a"
                    } 
                },
                new DummyDocument
                {
                    Name = "First",
                    CreatedAt = now.AddHours(-1),
                    Count= 0,
                    ComplexType = new DummyPropertyDocument
                    {
                        DummyString = "f"
                    } 
                }
            }
            .AsQueryable();

            var orderByRequest = new OrderByRequest("ComplexType.dummyString", OrderByDirection.Descending);
            orderByRequest.AddThenByRequest("count", OrderByDirection.Descending);

            var sortedData = source.DynamicOrderBy(
                orderByRequest);
            var expectedSortedData = source.OrderByDescending(document => document.ComplexType.DummyString).ThenByDescending(document => document.Count);

            sortedData.SequenceEqual(expectedSortedData).Should().BeTrue();
        }
 static void Main()
 {
     var studentsNames = new[] {new {firstName= "Petyr", lastName="Petrow"},
                               new {firstName= "Wasil", lastName="Atanasow"},
                               new {firstName= "Asen", lastName="Simeonow"}
                                 };
     var ordered =
         studentsNames.OrderByDescending(x => x.firstName).ThenByDescending(x => x.lastName);
 }
Ejemplo n.º 24
0
        public void GetSortExpressionDescendingForChainedParameter()
        {
            // Arrange
            var source = new[] { new MockQueryClass() }.AsQueryable();
            var expected = source.OrderByDescending(p => String.Concat(p.Name, p.Id)).Expression as MethodCallExpression;

            // Act
            var expression = QueryExtensions.GetSortExpression(source, new[] { "Name", "Id" }, ListSortDirection.Descending);

            AreExpressionsEqual(expected, expression);
        }
Ejemplo n.º 25
0
    private static string correct(string word)
    {
        var candidates =
            new[] { known(new[] {word}),
                    known(edits1(word)),
                    known_edits2(word),
                    new[] {word} }
                  .First(s => s.Any());

        return candidates.OrderByDescending(c => NWORDS(c) ?? 1).First();
    }
Ejemplo n.º 26
0
    static void Main()
    {
        var strings = new[]
        {
            "This long string",
            "This string",
            "The looooongest string",
            "Just a long string"
        };

        Console.WriteLine(strings.OrderByDescending(str => str.Length).First());
    }
        static void Main()
        {
            var names = new[]
                            {
                                "Goshkata",
                                "Pesho",
                                "Vasil",
                                "Hristofor"
                            };

            string longestStr = names.OrderByDescending(name => name.Length).First();
            Console.WriteLine("Longest string: {0}", longestStr);
        }
		static void Main()
		{
			var students = new[] {new { FirstName = "George", LastName = "Ivanov", Age = 18 },
						new { FirstName = "Ivan", LastName = "Georgiev", Age = 25 },
						new { FirstName = "Stefan", LastName = "Stefanov", Age = 22 } };

			var selected = students.OrderByDescending(student => student.FirstName).ThenByDescending(student => student.LastName);

			foreach (var item in selected)
				Console.WriteLine(item);


		}
 public void CustomComparer()
 {
     var source = new[]
     {
         new { Value = 1, Key = 15 },
         new { Value = 2, Key = -13 },
         new { Value = 3, Key = 11 }
     }.AsEnumerableWithCount();
     var query = source.OrderByDescending(x => x.Key, new AbsoluteValueComparer())
                       .Select(x => x.Value);
     Assert.AreEqual(3, query.Count);
     query.AssertSequenceEqual(1, 2, 3);
 }
 public void NullComparerIsDefault()
 {
     var source = new[]
     {
         new { Value = 1, Key = 15 },
         new { Value = 2, Key = -13 },
         new { Value = 3, Key = 11 }
     }.AsEnumerableWithCount();
     var query = source.OrderByDescending(x => x.Key, null)
                       .Select(x => x.Value);
     Assert.AreEqual(3, query.Count);
     query.AssertSequenceEqual(1, 3, 2);
 }