Update main_window.py

Add sorting function for history and contact list