OnGraph Interview Question

Soting and loops