Complete the code to sort the list of numbers in ascending order using LINQ.
var sortedNumbers = numbers.[1](n => n);The OrderBy method sorts elements in ascending order based on the key selector.
Complete the code to sort the list of strings by their length in descending order.
var sortedStrings = strings.OrderByDescending(s => s.[1]);The Length property gives the number of characters in a string, which is used here to sort by string length.
Fix the error in the code to sort a list of objects by their Age property in ascending order.
var sortedPeople = people.[1](p => p.Age);The correct LINQ method to sort by a key is OrderBy. Methods like Sort or SortBy do not exist in LINQ.
Fill both blanks to create a dictionary that maps each word to its length, but only include words longer than 3 characters.
var wordLengths = words.Where(w => w.[1] > 3).ToDictionary(w => w, w => w.[2]);
The Length property is used to get the number of characters in a string. We use it both to filter words longer than 3 and to get their length for the dictionary values.
Fill all three blanks to create a dictionary with uppercase words as keys and their lengths as values, including only words with length greater than 4.
var result = words.Where(w => w.[1] > 4).ToDictionary(w => w.[2](), w => w.[3]);
We filter words by their Length property, convert them to uppercase with ToUpper() for keys, and use Length again for values.