This script is flawed in the sense, that it requires that the zero bias calculation is first in the netcdf file.
What I would recommend to fix it, is something along the lines:
biases = [float(conf.calculator().electrodeVoltages()[1]-conf.calculator().electrodeVoltages()[0]) for conf in configurations ]
This will read all the biases into a list.
configurations = [configurations[i] for i in numpy.argsort(biases)]
This will resort the configurations according the biases and the rest of the script should work.
Add these two lines just below the nlread
# Read all configurations from NetCDF file
configurations = nlread(scf_filename, DeviceConfiguration)
biases = [float(conf.calculator().electrodeVoltages()[1]-conf.calculator().electrodeVoltages()[0]) for conf in configurations ]
configurations = [configurations[i] for i in numpy.argsort(biases)]
I hope this works - I haven't tried it yet, but it should work :)