OnGraph interview question

Soting and loops