Saya memiliki dua daftar array filelist
dan imgList
yang terkait satu sama lain, misalnya "H1.txt" yang terkait dengan "e1.jpg". Bagaimana cara secara acak daftar imgList
sesuai dengan pengacakanfileList
? Seperti di excel, jika kita mengurutkan kolom tertentu, kolom lainnya akan secara otomatis mengikuti?
String [] file = {"H1.txt","H2.txt","H3.txt","M4.txt","M5.txt","M6.txt"};
ArrayList<String> fileList = new ArrayList<String>(Arrays.asList(file));
String [] img = {"e1.jpg","e2.jpg","e3.jpg","e4.jpg","e5.jpg","e6.jpg"};
ArrayList<String> imgList = new ArrayList<String>(Arrays.asList(img));
//randomized files
Collections.shuffle(fileList);
output setelah pengacakan misalnya:
fileList = {"M4.txt","M6.txt","H3.txt","M5.txt","H2.txt","H1.txt"};
hasil yang diinginkan:
imgList = {"e4.jpg","e6.jpg","e3.jpg","e5.jpg","e2.jpg","e1.jpg"};