parse b6 output with sorting

def numBlast_sort(blast, numHits, evalueT, bitT):
    """
    parse b6 output with sorting
    """
    header = ['#query', 'target', 'pident', 'alen', 'mismatch', 'gapopen',
              'qstart', 'qend', 'tstart', 'tend', 'evalue', 'bitscore']
    yield header
    hmm = {h:[] for h in header}
    for line in blast:
        if line.startswith('#'):
            continue
        line = line.strip().split('\t')
        # Evalue and Bitscore thresholds
        line[10], line[11] = float(line[10]), float(line[11])
        evalue, bit = line[10], line[11]
        if evalueT is not False and evalue > evalueT:
            continue
        if bitT is not False and bit < bitT:
            continue
        for i, h in zip(line, header):
            hmm[h].append(i)
    hmm = pd.DataFrame(hmm)
    for query, df in hmm.groupby(by = ['#query']):
        df = df.sort_values(by = ['bitscore'], ascending = False)
        for hit in df[header].values[0:numHits]:
            yield hit