Sort:  

Thanks, hope it helps people in understanding the logic.