因此,基本上,我需要执行此任务,在其中我必须对一个文本文件进行排序,该文本文件包含一堆生日和名字,程序将根据生日更近,但考虑到leap年,同名人和日期相同,但年份不同。
我必须实现mergeSort或insertSort,但是我不确定如何实现。我能够使用这种方式对其进行排序,但是也许有人可以提供帮助?
private static ArrayList<Student> birthFix(ArrayList<Student> kids) {
ArrayList<Student> children = new ArrayList<>();
int o = kids.size();
Student kiddies = kids.get(0);
int amnt = 0;
for (int q = 0; q < o; q++) {
for (int r = 0; r < kids.size(); r++) {
Birthday p = hash.get(kiddies);
Student s = kids.get(r);
Birthday thebirth = hash.get(s);
if(s.full != kiddies.full)
{
if(thebirth.mon < p.mon)
{
kiddies = s;
amnt = r;
} else if (thebirth.mon == p.mon)
{
int chart = p.compare(p, thebirth);
if (chart > 0) {
kiddies = s;
amnt = r;
} else if (chart == 0 && r > amnt)
{
kiddies = s;
amnt = r;
}
}
}
}
children.add(kids.remove(amnt));
if(kids.size()>0)
{
kiddies = kids.get(0);
amnt = 0;
}
}
return children;
}