public static int get_order(int[] input1)
{
var sortedArray = input1.OrderByDescending(o => o).ToArray();
var unsortedArray = input1;
int temp1;
int swap = 0;
int arrayLength = sortedArray.Length;
for (int i = 0; i < arrayLength; i++)
{
if (sortedArray[i] != unsortedArray[i])
{
temp1 = unsortedArray[i];
unsortedArray[i] = sortedArray[i];
for (int j = i + 1; j < arrayLength; j++)
{
if (unsortedArray[j] == sortedArray[i])
{
unsortedArray[j] = temp1;
swap++;
break;
}
}
}
}
return swap;
}
Invoke it as
static void Main(string[] args)
{
int[] number = { 3,1,2};
int result = get_order(number);
Console.ReadKey();
}