<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _get_program_gates(prog):
 """ Get all gate applications appearing in prog. :param Program prog: The program :return: A list of all Gates in prog (without duplicates). :rtype: List[Gate] """

    return sorted({i for i in prog if isinstance(i, Gate)}, key=lambda g: g.out())