i am not able to understand how it gives this output and how compare function work . pls explain in details