Implemented below mentioned changes :

1. Extract if condition to separate funciton
2. Maintain sorted countries after each drop