Sorting an arraylist based on objects value in another arraylist in Java
问题 I have an issue with sorting an Array List. In a class i have two Array Lists of different objects, we can call the objects Foo and Bar. public class Foo() { int value; //Some other fields, and setters and getters. } public class Bar() { int id; //Same here... } So the list fooList can be totally scrambeled. Say that i have 16 Foos, but Foo with value 5 can be on index 13 and so on. What i'm trying to do is to order barList to match fooList after these values. If Foo with value 5 is on index