的列表的顺序这是我有:排序对象的列表与对象ID
class Person {
Integer id;
String name;
}
// A list of persons:
List<Person> persons
// Now I have something like this:
List<Integer> ids // where the ids are stored in an specific order
基本上我以相同的顺序,如IDS想排序的人员名单。
有没有更好的方法,然后像两个循环一样使用并创建一个新的Person-List?
问候& & TIA
noircc
复杂性是什么? – 2012-04-25 16:13:26
Collections.sort是O(nlogn),但是对于每个比较都有两个O(n)索引查找,所以不能非常有效,但至少没有创建临时收藏。 – dogbane 2012-04-25 16:36:31
恩,谢谢! – noircc 2012-04-26 07:43:20