//using lambda predicate
 public static void OrderStudentsByNameLambda(Student[] arr)
 {
     var ordered = arr.OrderByDescending(s => s.FirstName).ThenByDescending(s => s.LastName);
     int counter = 0;
     foreach (var student in ordered)
     {
         arr[counter] = student;
         counter++;
     }
 }
Exemple #2
0
        public static void OrderStudents(Student[] students)
        {
            var result = students
                .OrderByDescending(student => student.FirstName)
                .ThenByDescending(student => student.LastName);
            Console.WriteLine("Sort descending with extension metods: {0}", string.Join(", ", result).ToString());

            Console.WriteLine();

              result =
                from student in students
                orderby student.FirstName descending,
                student.LastName descending
                select student;
            Console.WriteLine("Sort descending with LINQ: {0}", string.Join(", ", result).ToString());
        }