import logging


def _check_exon_order(data_frame, row_index, prev_row_index, exon_pos):
    """
    Check that exons are ordered by rank in the transcript.

    Return True if everything is OK.
    """
    exon_id = data_frame.loc[row_index, 'ExonID']
    transcript_id = data_frame.loc[row_index, 'TranscriptID']
    if (exon_pos != 0) and (data_frame.loc[row_index, 'ExonRank'] <=
                            data_frame.loc[prev_row_index, 'ExonRank']):
        logging.warning("Exons aren't sorted by rank (%s, %s).", transcript_id,
                        exon_id)
        return False
    return True