\begin{Verbatim}[commandchars=\\\{\}]
\PYG{k+kn}{from} \PYG{n+nn}{Bio} \PYG{k+kn}{import} \PYG{n}{SeqIO}

\PYG{n}{records} \PYG{o}{=} \PYG{n+nb}{list}\PYG{p}{(}\PYG{n}{SeqIO}\PYG{o}{.}\PYG{n}{parse}\PYG{p}{(}\PYG{l+s+s2}{\PYGZdq{}ls\PYGZus{}orchid.fasta\PYGZdq{}}\PYG{p}{,} \PYG{l+s+s2}{\PYGZdq{}fasta\PYGZdq{}}\PYG{p}{))}
\PYG{n}{records}\PYG{o}{.}\PYG{n}{sort}\PYG{p}{(}\PYG{n}{key}\PYG{o}{=}\PYG{k}{lambda} \PYG{n}{r}\PYG{p}{:} \PYG{n+nb}{len}\PYG{p}{(}\PYG{n}{r}\PYG{p}{))}
\PYG{n}{SeqIO}\PYG{o}{.}\PYG{n}{write}\PYG{p}{(}\PYG{n}{records}\PYG{p}{,} \PYG{l+s+s2}{\PYGZdq{}sorted\PYGZus{}orchids.fasta\PYGZdq{}}\PYG{p}{,} \PYG{l+s+s2}{\PYGZdq{}fasta\PYGZdq{}}\PYG{p}{)}
\end{Verbatim}
