try {
if (answers == null) {
return servers;
}
MXRecord mxAnswers[] = new MXRecord[answers.length];
for (int i = 0; i < answers.length; i++) {
mxAnswers[i] = (MXRecord)answers[i];
}
Comparator prioritySort = new Comparator () {
public int compare (Object a, Object b) {
MXRecord ma = (MXRecord)a;
MXRecord mb = (MXRecord)b;
return ma.getPriority () - mb.getPriority ();
}
};
Arrays.sort(mxAnswers, prioritySort);