Sample order was not mained while using DataLoader

Order of samples set by datasets.ImageFolder was not maintained while using SequentialSampler for DataLoader across mutiple batches.

If I load my dataset using
image_datasets = {x: datasets.ImageFolder(os.path.join(data_dir, x),
for x in [‘train’, ‘test’]}

There is an oder of samples defined in image_datasets[‘test’],imgs (gives list of tuples where each tuple has path to the sample and its label)

I am trying to maintain same order of samples across batches while using dataLoader, I assumed if I set the sampler to SequentialSampler then samples loaded across multiple batch will follow the same oder set by ImageFolder.imgs. But that was not the case.

dataloaders['test'] =['test'],
                                            shuffle=False, num_workers=1)

Is there any other way to achieve the same?

My bad, SequentialSampler was maintaining order.