Java Java Data Structures Organizing Data Interfaces

Can anyone please explain the code?

I am not able to understand compareTo method and its functionality, whatever Craig wrote code in this tutorial. If anyone please explain me line by line. I highly appreciate it. Thank you