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;
- using System.Threading.Tasks;
- namespace SortArrayOfSrtings
- {
- class Program
- {
- static void Main(string[] args)
- {
- string [] array = Console.ReadLine().Split(' ').ToArray();
- BubbleSort(array);
- Console.WriteLine(string.Join(" ", array));
- }
- static void BubbleSort(string[] array)
- {
- while (true)
- {
- bool swap = false;
- for (int index = 0; index < array.Length - 1; index++)
- {
- if (string.Compare( array[index], array[index + 1]) > 0) //if first number is greater then second then swap
- {
- var temp = array[index];
- array[index] = array[index + 1];
- array[index + 1] = temp;
- swap = true;
- }
- }
- if (!swap)
- {
- break;
- }
- }
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement