#include "sortaction.h"
#include "reverseaction.h"
+#include "genealgorithms.h"
+
+#include <queue>
using namespace std;
-GeneSorter::ActionList GeneSorter::sort(const GeneOrder& go1){
- return ActionList();
+GeneSorter::ActionList GeneSorter::sort(const GeneOrder& go){
+ ActionList al;
+ GeneOrder temp(go);
+ while(inversionDistance(go) > 0){
+ ActionList safe = safeActions(go);
+ if (safe.size() > 0){
+ safe[0](temp);
+ al.push_back(safe[0]);
+ }else
+ return ActionList(); //TODO: Need to handle hurdles.
+ }
+ return al;
}
-GeneSorter::ActionList GeneSorter::safeActions(const GeneOrder& go1){
- return ActionList();
+GeneSorter::ActionList GeneSorter::safeActions(const GeneOrder& go){
+ if (countCycles(go) == go.size() - 1)
+ return ActionList();
+ ActionList al;
+ //al.push_back(SortAction(new ReverseAction(2,3)));
+ return al;
}