package main;
import java.util.Comparator;
public class ResolutionComparer implements Comparator<String> {
@Override
public int compare(String resA, String resB) {
String[] modeA = resA.split("x");
String[] modeB = resB.split("x");
int widthA = Integer.valueOf(modeA[0]).intValue();
int heightA = Integer.valueOf(modeA[1]).intValue();
int widthB = Integer.valueOf(modeB[0]).intValue();
int heightB = Integer.valueOf(modeB[1]).intValue();
if(widthA != widthB) return (widthA > widthB) ? 1 : -1;
if(heightA != heightB) return (heightA > heightB) ? 1 : -1;
return 0;
}
}
|