I think you are sorting the proteins in an odd way. I think the for loop is supposed iterate over a list of proteins IDs based off the number of peptides (from largest to smallest). I think this loop actually sorting from the total length, in aa, of the peptides sequences.
https://github.com/wfondrie/mokapot/blob/ca5a8dfd72d57156f0a8420ce17b6c1199e4dba7/mokapot/parsers/fasta.py#L535C5-L535C74
I think you are sorting the proteins in an odd way. I think the for loop is supposed iterate over a list of proteins IDs based off the number of peptides (from largest to smallest). I think this loop actually sorting from the total length, in aa, of the peptides sequences.