c# sort for loop

C#
public static void Main(string[] args)
        {
            int[] arr = { 5,4,3,2,1 };
            Sorting(arr);
        }
        public static void Sorting(int[] arr)
        {
            int length = arr.Length;

            for (int i = 0; i < length - 1; i++)
            {   //length-1 b/c i+1 will put you OOB

                if (arr[i] > arr[i + 1])
                {//For descending order...skips to next index if false

                    int temp = arr[i];
                    arr[i] = arr[i + 1];
                    arr[i + 1] = temp;

                    i = -1; //sort from lowest out of order index
                }
            }
            foreach (int item in arr)
            {
                Console.WriteLine(item);
            }
        }   
Source

Also in C#: