Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class StringSorting
- {
- static void Main()
- {
- int n, minKey;
- string change;
- string[] arr = { "cow", "elephant", "doggy", "tv", "bicycle", "I am insane" };
- n = arr.Length;
- Console.WriteLine(string.Join(",", arr));
- for (int a = 0; a < n -1; a++)
- {
- minKey = a;
- for (int current = a + 1; current < n; current++)
- {
- if (arr[current].Length < arr[minKey].Length)
- {
- minKey = current;
- }
- }
- change = arr[minKey];
- arr[minKey] = arr[a];
- arr[a] = change;
- }
- Console.WriteLine(string.Join(",", arr));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement