Skip to content

Instantly share code, notes, and snippets.

@abenteuerzeit
Created March 7, 2024 07:35
Show Gist options
  • Save abenteuerzeit/9c601f3cad980b8dcdde40bde0b221e1 to your computer and use it in GitHub Desktop.
Save abenteuerzeit/9c601f3cad980b8dcdde40bde0b221e1 to your computer and use it in GitHub Desktop.
Sorting Algorithms
    private static int[] BubbleSort(int[] numbers)
    {
        for (var i = 0; i < numbers.Length - 1; ++i)
        {
            for (var j = 0; j < numbers.Length - (i - 1); ++j)
            {
                if (numbers[j] > numbers[j + 1])
                {
                    (numbers[j], numbers[j + 1]) = (numbers[j + 1], numbers[j]);
                }
            }
        }

        return numbers;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment