Comparator based on a configurable order

后端 未结 4 1519
一生所求
一生所求 2020-12-09 11:33

Is there a way to write custom comparator, following this example:

There are at most 10 items coming in at a random order i.e.

first item:  item_one         


        
4条回答
  •  难免孤独
    2020-12-09 12:17

    Use Guava's com.google.common.collect.Ordering:

    Ordering.explicit(second_one, third_one, first_one);
    

提交回复
热议问题