I want to switch the position of elements in my list based on a rule.
I have a Map which has some data:
Map<String,List<Person>> workDivision = [:]
//inserted data to map...
I'm looping the map and based on a rule I want to move the element in the list to back of the list.So I'm first removing the element and then inserting it again.
workDivision.each {String division, List<Person> list -> {
if(list.size>1 && someRule = true) {
for(int i = 0; i<list.size; i++) {
Person p = list.get(i)
list.remove(i)
list.add(p)
}
}
}
The above code is not working and I don't know why. Can anybody check if I'm missing something or completly doing it wrong?