import java.util.*;
class SortOrder {
public static final Map
<String, Integer
> SORT_ORDER
= initializeSortOrder
();
private static Map
<String, Integer
> initializeSortOrder
() { List
<String
> orderedStrings
= Arrays.
asList( "A",
"B",
"D",
"C",
"E",
"F"
);
Map
<String, Integer
> indexByString
= new HashMap
<>(); for (int index = 0; index < orderedStrings.size(); ++index) {
indexByString.put(orderedStrings.get(index), index);
}
}
public static void main
(String[] args
) { List
<String
> testData
= new ArrayList
<>(Arrays.
asList( "B", "C", "D", "E", "A"
));
@Override
return SORT_ORDER.get(s1).compareTo(SORT_ORDER.get(s2));
}
});
}
}
aW1wb3J0IGphdmEudXRpbC4qOwoKY2xhc3MgU29ydE9yZGVyIHsKICAgIHB1YmxpYyBzdGF0aWMgZmluYWwgTWFwPFN0cmluZywgSW50ZWdlcj4gU09SVF9PUkRFUiA9IGluaXRpYWxpemVTb3J0T3JkZXIoKTsKCiAgICBwcml2YXRlIHN0YXRpYyBNYXA8U3RyaW5nLCBJbnRlZ2VyPiBpbml0aWFsaXplU29ydE9yZGVyKCkgewogICAgICAgIExpc3Q8U3RyaW5nPiBvcmRlcmVkU3RyaW5ncyA9IEFycmF5cy5hc0xpc3QoCiAgICAgICAgICAgICAgICAiQSIsCiAgICAgICAgICAgICAgICAiQiIsCiAgICAgICAgICAgICAgICAiRCIsCiAgICAgICAgICAgICAgICAiQyIsCiAgICAgICAgICAgICAgICAiRSIsCiAgICAgICAgICAgICAgICAiRiIKICAgICAgICApOwogICAgICAgIE1hcDxTdHJpbmcsIEludGVnZXI+IGluZGV4QnlTdHJpbmcgPSBuZXcgSGFzaE1hcDw+KCk7CiAgICAgICAgZm9yIChpbnQgaW5kZXggPSAwOyBpbmRleCA8IG9yZGVyZWRTdHJpbmdzLnNpemUoKTsgKytpbmRleCkgewogICAgICAgICAgICBpbmRleEJ5U3RyaW5nLnB1dChvcmRlcmVkU3RyaW5ncy5nZXQoaW5kZXgpLCBpbmRleCk7CiAgICAgICAgfQogICAgICAgIHJldHVybiBDb2xsZWN0aW9ucy51bm1vZGlmaWFibGVNYXAoaW5kZXhCeVN0cmluZyk7CiAgICB9CgogICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgICAgIExpc3Q8U3RyaW5nPiB0ZXN0RGF0YSA9IG5ldyBBcnJheUxpc3Q8PihBcnJheXMuYXNMaXN0KAogICAgICAgICAgICAgICAgIkIiLCAiQyIsICJEIiwgIkUiLCAiQSIKICAgICAgICApKTsKCiAgICAgICAgQ29sbGVjdGlvbnMuc29ydCh0ZXN0RGF0YSwgbmV3IENvbXBhcmF0b3I8U3RyaW5nPigpIHsKICAgICAgICAgICAgQE92ZXJyaWRlCiAgICAgICAgICAgIHB1YmxpYyBpbnQgY29tcGFyZShTdHJpbmcgczEsIFN0cmluZyBzMikgewogICAgICAgICAgICAgICAgcmV0dXJuIFNPUlRfT1JERVIuZ2V0KHMxKS5jb21wYXJlVG8oU09SVF9PUkRFUi5nZXQoczIpKTsKICAgICAgICAgICAgfQogICAgICAgIH0pOwoKICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4odGVzdERhdGEpOwogICAgfQoKfQo=