def sort_recs(recs, chromosome_list=[], split_char="|"):
    """Sort a list of Bio.SeqRecord according to the chromosome, position, length.

    Parameters
    ----------
    recs : list of Bio.SeqRecord
    chromosome_list : list of str
        A list specifying the order of the chromosomes (as python doesn't really natural sort lists)
    split_char : str
        The delimiter used for splitting the record.id

    Returns
    -------
    list of Bio.SeqRecord
        Records properly sorted
    """

    def sort_func(item):
        """we sort according to chromosomes
        our header is >16|kraken:taxid|9906|69694935_57 ...
        use split to access the first element
        last element is pos_length
        """
        chrom = item.id.split(split_char)[0]
        pos, l = item.id.split(split_char)[-1].split("_")
        if chromosome_list:
            return (chromosome_list.index(chrom), int(pos), int(l))
        else:
            return (int(pos), int(l))

    return sorted(recs, key=sort_func)