Custom Sorting of List

前端 未结 5 916
清酒与你
清酒与你 2021-01-21 03:11

I have a List where T is my Event type which has a field time of type long. This list is populated from

5条回答
  •  情深已故
    2021-01-21 03:38

    You should do something like this:

     if(x.time==y.time) return 0;
     if(x.time==0) return 1;
     return x.time - y.time;
    

    The point here is that 0 is larger than any other time, so it'll be placed at the end of the list.

提交回复
热议问题