optimized angry children using sorting