I want to sort the following objects in the class. Each Element object has two field from and to. Here for e1 null is from v0 is to . I want to sort the elements as (null,v0),(v0,v1).....
public class Test7 {
public static void main(String[] args) {
Element e1 = new Element(null,"v0");
Element e2 = new Element("v0","v1");
Element e3 = new Element("v1","v2");
Element e4 = new Element("v2","v3");
Element e5 = new Element("v3","v4");
Element e6 = new Element("v4","v5");
List<Element> elementList = new ArrayList();
elementList.add(e3);
elementList.add(e2);
elementList.add(e1);
elementList.add(e5);
elementList.add(e6);
elementList.add(e4);
}
}
Can someone help me on this?