Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace _05.StringsSortByLength
- {
- class StringsSortByLength
- {
- static void Main(string[] args)
- {
- Console.Write("Number of words: ");
- int number = int.Parse(Console.ReadLine());
- string[] words = new string[number];
- for (int i = 0; i < number; i++)
- {
- words[i] = Console.ReadLine();
- }
- words = words.OrderBy(word => word.Length).ToArray();
- Console.WriteLine("Sorted by length array is:");
- Array.ForEach(words, Console.WriteLine);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement