import
java.util.ArrayList;
import
java.util.Collections;
import
java.util.Comparator;
import
java.util.List;
public
class
Main {
static
class
ItemComparator
implements
Comparator<Pair<String, Integer>> {
@Override
public
int
compare(Pair<String, Integer> A, Pair<String, Integer> B) {
if
(A.getValue().equals(B.getValue())) {
return
A.getKey().compareTo(B.getKey());
}
return
B.getValue() - A.getValue();
}
}
public
static
void
main(String[] args) {
int
k =
2
;
int
n =
3
;
List<Pair<String, Integer>> items =
new
ArrayList<>();
items.add(
new
Pair<>(
"Bat"
,
100
));
items.add(
new
Pair<>(
"Gloves"
,
50
));
items.add(
new
Pair<>(
"Wickets"
,
200
));
items.add(
new
Pair<>(
"Ball"
,
100
));
Collections.sort(items,
new
ItemComparator());
for
(
int
i =
0
; i < Math.min(n, k); i++) {
System.out.println(items.get(i).getKey());
}
}
static
class
Pair<K, V> {
private
final
K key;
private
final
V value;
public
Pair(K key, V value) {
this
.key = key;
this
.value = value;
}
public
K getKey() {
return
key;
}
public
V getValue() {
return
value;
}
}
}