How to implement the following simple comparison function - Modular