using System;

class QuicksortDemo
{
    static void Quicksort(int[] numbers, int start, int end)
    {
        int l = start;
        int r = end;
        int tmp;
        int comp = numbers[(l + r) / 2];

        do
        {
            while ((numbers[l] < comp) && (l < end)) l++;
            while ((numbers[r] > comp) && (r > start)) r--;

            if (l <= r)
            {
                tmp = numbers[l];
                numbers[l] = numbers[r];
                numbers[r] = tmp;
                l++;
                r--;
            }
        } while (l <= r);

        if (start < r)
            Quicksort(numbers, start, r);
        if (l < end)
            Quicksort(numbers, l, end);
    }

    static void Main()
    {
        int[] temperatures = { 12, -2, 34, 24, 8, 24, 22 };

        Quicksort(temperatures, 0, temperatures.Length - 1);

        foreach (int n in temperatures)
            Console.Write(n + " ");

        Console.WriteLine();
    }
}