Pregunta de entrevista de RBC Investor Services

Bubble Sorting algorithm in Python? How can you optimize the code?