Skip to content

Instantly share code, notes, and snippets.

@dzimchuk
Created December 11, 2015 14:13
Show Gist options
  • Save dzimchuk/5ebef5a3d185bd393003 to your computer and use it in GitHub Desktop.
Save dzimchuk/5ebef5a3d185bd393003 to your computer and use it in GitHub Desktop.
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