I do not think that Guwa has anything specific for this. But this is just a matter of writing this comparator:
Collections.sort(userList, new Comparator<User>() { @Override public int compare(User u1, User u2) { int i1 = idList.indexOf(u1.getId()); int i2 = idList.indexOf(u2.getId()); return Ints.compare(i1, i2); } }
Now that I think about it, it can also be implemented as follows:
final Ordering<Integer> idOrdering = Ordering.explicit(idList); Collections.sort(userList, new Comparator<User>() { @Override public int compare(User u1, User u2) { return idOrdering.compare(u1.getId(), u2.getId()); } }
which is probably more efficient.
Jb nizet
source share