Reference citation2 = o2.getCitation();
// the newly created should always be on top
- if (id1 == 0) {
+ if (id1 == 0 && id2!=0) {
return -1;
}
- if (id2 == 0) {
+ if (id1 != 0 && id2==0) {
return 1;
}
// sort by type (Primary taxonomic > Primary Media > others
// alphabetically by reference title cache)
- if (type1 != null && type1.equals(OriginalSourceType.PrimaryTaxonomicSource)) {
- return -1;
+ if (type1 != null && type1.equals(OriginalSourceType.PrimaryTaxonomicSource)
+ && type2 != null && !type2.equals(OriginalSourceType.PrimaryTaxonomicSource)) {
+ return -1;
+ }
+ if (type1 != null && !type1.equals(OriginalSourceType.PrimaryTaxonomicSource)
+ && type2 != null && type2.equals(OriginalSourceType.PrimaryTaxonomicSource)) {
+ return 1;
}
if (type1 != null && type1.equals(OriginalSourceType.PrimaryMediaSource)
&& type2!=null && !type2.equals(OriginalSourceType.PrimaryTaxonomicSource)) {
return -1;
}
- if (type2 != null && type2.equals(OriginalSourceType.PrimaryTaxonomicSource)) {
- return 1;
- }
if (type2 != null && type2.equals(OriginalSourceType.PrimaryMediaSource)
&& type1!=null && !type1.equals(OriginalSourceType.PrimaryTaxonomicSource)) {
return 1;
}
//sort by citation title cache
- if(citation1==null){
- return -1;
- }
- if(citation2==null){
- return 1;
- }
if(citation1!=null && citation2!=null){
return citation1.getTitleCache().compareTo(citation2.getTitleCache());
}
- return 0;
+ return o2.getCreated().compareTo(o1.getCreated());
}
});
return sources;