using
System;
using
System.Collections.Generic;
public
class
GFG{
class
pair : IComparable<pair>
{
public
int
first, second;
public
pair(
int
first,
int
second)
{
this
.first = first;
this
.second = second;
}
public
int
CompareTo(pair b)
{
if
(
this
.first != b.first)
return
(
this
.first < b.first)?-1:1;
else
return
this
.second > b.second?-1:1;
}
}
public
static
void
Main(String[] args)
{
List<pair > vect =
new
List<pair > ();
int
[]arr = { 10, 10, 5, 5, 15, 15 };
int
[]arr1 = { 40, 60, 20, 50, 12, 24 };
int
n = arr.Length;
for
(
int
i = 0; i < n; i++)
vect.Add(
new
pair(arr[i],
arr1[i]));
Console.Write(
"The vector before sort operation is:\n"
);
for
(
int
i = 0; i < n; i++)
{
Console.Write(vect[i].first+
" "
+ vect[i].second +
"\n"
);
}
vect.Sort();
Console.Write(
"The vector after sort operation is:\n"
);
for
(
int
i = 0; i < n; i++)
{
Console.Write(vect[i].first+
" "
+ vect[i].second +
"\n"
);
}
}
}