Hi guys,
Cameron, thanks for the points. In fact the file name contains multiple '_' characters. So, I appreciate what you recommended. filenames = {} for name in glob.glob('*chunk_*'): left, right = name.rsplit('_', 1) if left.endswith('chunk') and right.isdigit(): filenames[int(right)] = filename sorted_filenames = [ filenames[k] for k in sorted(filenames.keys()) ] It seems that 'filename' should be 'right'. Regards, Mahmood -- https://mail.python.org/mailman/listinfo/python-list