January 2012
Intermediate to advanced
396 pages
8h 16m
English
Follow the given steps:
string[] fruits = { "grape", "passionfruit", "banana", "apple", "orange", "raspberry", "mango", "blueberry" };
//Sort the strings first by their length.
var sortedFruits = fruits.OrderBy(fruit => fruit.Length);
sortedFruits.Dump("Sorted Fruits by Length");
So you see the fruit names are sorted in ascending order of their length.
Now, let's see what happens if we sort the elements alphabetically, maintaining this primary sorting as per their length.
Read now
Unlock full access