// C# program to demonstrate the use
// of Array.Sort(Array, Array, Int32,
// Int32, IComparer) Method
using System;
using System.Collections;
class comparer : IComparer {
// Call CaseInsensitiveComparer.Compare
public int Compare(Object x, Object y)
{
return (new CaseInsensitiveComparer()).Compare(y, x);
}
}
// Driver Class
class GFG {
// Main Method
public static void Main()
{
// initialize two Arrays
String[] arr1 = {"H", "J", "K",
"L", "I", "N", "M"};
String[] arr2 = {"A", "E", "D",
"C", "F", "B", "G"};
// Instantiate the reverse comparer.
IComparer g = new comparer();
// Display original values of the array.
Console.WriteLine("The original order of "+
"elements in the array:");
Display(arr1, arr2);
// Sort a section of the array
// using the IComparer object
// sorting happens in the range
// of index 1 to 4
// "g" is IComparer object
Array.Sort(arr1, arr2, 1, 4, g);
Console.WriteLine("\nAfter sorting in a "+
"range of index 1 to 4 :");
Display(arr1, arr2);
}
// Display function
public static void Display(String[] arr1, String[] arr2)
{
for (int i = 0; i < arr1.Length; i++)
{
Console.WriteLine(arr1[i] + " : " + arr2[i]);
}
}
}