The order of filenames is determined by the order provided in the opf spine.
That utility method can be found in epub_utils.py here:
https://github.com/Sigil-Ebook/Sigil.../epub_utils.py
It assumes you have built a proper unpacked epub at ebook_path (directory where the mimetype file exists) and simply creates the zip from it properly special casing the mimetype file.
There are also helper routines to create a container.xml, deal with obfuscating fints if needed, etc.
Hope this helps,
Kevin