how to Manually shuffle the array list
arraylist, java
Solution
Here I found Solution to my question please observer here. "itemList_dump" is an arraylist which contains data.
if (i < itemList_dump.size()) {
MyBitamp Data = itemList_dump.get(original_position_val);
// setting Values according to our algorithm
Data.setItemCurPos(original_position_val);
Data.setItemPosition(current_positon_val);
Data.setrotation(rotataion_val);
}
}
Collections.sort(itemList_dump, new Comparator<MyBitamp>() {
@Override
public int compare(MyBitamp o1, MyBitamp o2) {
if (o1.getItemPosition() > o2.getItemPosition()) {
return 1;
} else if (o1.getItemPosition() < o2.getItemPosition()) {
return -1;
} else {
return 0;
}
}
});
Problem
I have an arraylist contains some values that are in an order (correct positions), Now I want to swipe/set/manual shuffle change the values into disorder of the arraylist. Below image can give my idea.Change Array-II to Array-I. To shuffle we can use collection.shuffle(), but here I have a text file, in that text file i wrote a original position as well as current position of the data in the array on to the text file. for example imaging, we have a text file name MyFile.txt, I wrote data in that like this, "original_position~Current_position" for example 0~0 1~2 2~4 3~3 4~1 so, based on the above data i would to shuffle/ set the array.