def _sort_triangle_indices(triangles):
    """Sorts indices of each triangle so lowest index always comes first.
    Also removes degenerate triangles.

    >>> list(_sort_triangle_indices([(2,1,3),(0,2,6),(9,8,4)]))
    [(1, 3, 2), (0, 2, 6), (4, 9, 8)]
    >>> list(_sort_triangle_indices([(2,1,1),(0,2,6),(9,8,4)]))
    [(0, 2, 6), (4, 9, 8)]
    """
    for t0, t1, t2 in triangles:
        if t0 == t1 or t1 == t2 or t2 == t0:
            continue
        if t0 < t1 and t0 < t2:
            yield t0, t1, t2
        elif t1 < t0 and t1 < t2:
            yield t1, t2, t0
        elif t2 < t0 and t2 < t1:
            yield t2, t0, t1
        else:
            raise RuntimeError(
                'Unexpected error while sorting triangle indices.')
