def chr_less(chr_left, chr_right, sorted_lex):
    """
    Returns true if the left chromosome comes before the right or is the same.

    Args:
        chr_left = (string) the left chromsome being compared
        chr_right = (string) the right chromosome being compared
        sorted_lex = true if file sorted lexicographically (by string values)

    Returns: Whether or not left chromosome comes before the right (boolean).
    """

    # True if the file is sorted lexicographically
    # i.e. chr1 < chr11 < chr2 < chrX < chrY
    if sorted_lex:
        return (chr_left < chr_right)

    # False if the file is sorted numerically
    # i.e. chr1 < chr2 < chr11 < chrX < chrY
    else:
        left = chr_left[3:]    # assumes chromosome name is chr<other bits>
        right = chr_right[3:]
        try:
            l_num = int(left)
            try:
                r_num = int(right)
                return l_num < r_num
            # Right chromosome is a string (chrX, chrY, chrTest, etc)
            except:
                # Left is a number and right is a string
                # Numbers are sorted before strings (chr1 < chrX)
                return True
        # Left number is a string if get to ValueError exception
        except ValueError:
            try:
                r_num = int(left)
                # Left is a string and right is a number
                # Numbers are sorted before strings (chrX !< chr1)
                return False
            # Both are strings, sort lexicographically
            except ValueError:
                return chr_left < chr_right