Infilect interview question

Question on stack, sorting, python