Created
December 11, 2015 14:13
-
-
Save dzimchuk/5ebef5a3d185bd393003 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void BubbleSort(IComparable[] elements) | |
{ | |
for (int i = 0; i < elements.Length - 1; i++) | |
{ | |
for (int j = 0; j < elements.Length - 1 - i; j++) | |
{ | |
if (elements[j].CompareTo(elements[j + 1]) > 0) | |
{ | |
var temp = elements[j]; | |
elements[j] = elements[j+1]; | |
elements[j+1] = temp; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment