def partition_esps_and_esms(filelist):
    """Split filelist into separate lists for esms and esps, retaining order."""
    esm_files = []
    esp_files = []
    for filename in filelist:
        ext = filename[-4:].lower()
        if ext == ".esp":
            esp_files.append(filename)
        elif ext == ".esm":
            esm_files.append(filename)
    return (esm_files, esp_files)