I checked many samples but I couldn't figure out how could I implement Comparator or another method with my problem . I try to explain my problem clearly . I have an arrayList as follow : my Datamodel include an int as id and a String as name for each object ;
arrayList 1 = {id=0 - value= "name0", id=1 - value= "name1" , id = 2 - value = "name2"};
my second Arraylist also include an datamodel with more items but it include also the value of fisrt arrayList as follow :
arrayList 2 = {id = 100 - age = 20 - value ="name2",id = 101 - age = 21 - value ="name0",id = 102 - age = 18 - value ="name1"};
now I want to sort the second arrayList based on firstArrayList(value order) as follow :
orderedArrayList = {id = 101 - age = 21 - value ="name0",id = 102 - age = 18 - value ="name1",id = 100 - age = 20 - value ="name2"}
how Can achieve that?Can somebody help me to do this ? My android api is 21 also .