Sorting of image file for pass code generation