-
-// void FGAISchedule::setClosestDistanceToUser()
-// {
-
-
-// double course;
-// double dist;
-
-// time_t
-// totalTimeEnroute,
-// elapsedTimeEnroute;
-
-// double userLatitude = fgGetDouble("/position/latitude-deg");
-// double userLongitude = fgGetDouble("/position/longitude-deg");
-
-// FGAirport *dep;
-
-// #if defined( __CYGWIN__) || defined( __MINGW32__)
-// #define HUGE HUGE_VAL
-// #endif
-// distanceToUser = HUGE;
-// FGScheduledFlightVecIterator i = flights.begin();
-// while (i != flights.end())
-// {
-// dep = i->getDepartureAirport();
-// //if (!(dep))
-// //return HUGE;
-
-// SGWayPoint user ( userLongitude,
-// userLatitude,
-// i->getCruiseAlt());
-// SGWayPoint current (dep->getLongitude(),
-// dep->getLatitude(),
-// 0);
-// user.CourseAndDistance(current, &course, &dist);
-// if (dist < distanceToUser)
-// {
-// distanceToUser = dist;
-// //cerr << "Found closest distance to user for " << registration << " to be " << distanceToUser << " at airport " << dep->getId() << endl;
-// }
-// i++;
-// }
-// //return distToUser;
-// }
+bool FGAISchedule::operator< (const FGAISchedule &other) const
+{
+ //cerr << "Sorting " << registration << " and " << other.registration << endl;
+ double currentScore = score * (1.5 - lastRun);
+ double otherScore = other.score * (1.5 - other.lastRun);
+ return currentScore > otherScore;
+}