Python Global Variable Not Defined In Python How To Sort