package com.xm.officialaccounts.utils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author
* @date created in 17:03 2021/6/4
*/
public class a implements Comparable{
int a;
int b;
@Override
public int compareTo(Object o) {
a other = (a)o;
if(b == 4 || b == 5){
if(other.b == 4 || other.b == 5){
// 都是a=0级别
return 0;
}else {
return 0 > other.a ? -1 :1;
}
}else {
if(other.b == 4 || other.b == 5){
return a > 0 ? -1:1;
}else {
return a > other.a ? -1:1;
}
}
}
public a(int a,int b){
this.a = a;
this.b = b;
}
public static void main(String[] args) {
List<a> list = new ArrayList<>();
a a1 = new a(1,4);
a a2 = new a(0,3);
a a3 = new a(0,5);
a a4 = new a(0,2);
a a5 = new a(1,5);
a a6 = new a(1,1);
a a7 = new a(0,0);
a a8 = new a(1,5);
list.add(a1);list.add(a2);list.add(a3);list.add(a4);list.add(a5);list.add(a6);list.add(a7);list.add(a8);
Collections.sort(list);
list.stream().forEach(t ->System.out.println(t.a+"========="+t.b));
}
/* 1=========1
1=========4
0=========3
0=========5
0=========2
1=========5
0=========0
1=========5*/
}