Skip to content

Commit

Permalink
Update sort.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
pbeckingham committed Feb 7, 2019
1 parent 803f4a5 commit 32d14bc
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/sort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ void sort_tasks (
const std::string& keys)
{
Timer timer;

global_data = &data;

// Split the key defs.
Expand All @@ -76,16 +75,18 @@ void sort_projects (
for (auto& parent : parents)
{
parent_pos = std::find_if (sorted.begin (), sorted.end (),
[&parent](const std::pair <std::string, int>& item) { return item.first == parent; }
);
[&parent](const std::pair <std::string, int>& item) { return item.first == parent; });

// if parent does not exist yet: insert into sorted view
if (parent_pos == sorted.end ()) {
if (parent_pos == sorted.end ())
sorted.push_back (std::make_pair (parent, 1));
}
}

// insert new element below latest parent
sorted.insert ((parent_pos == sorted.end ()) ? parent_pos : ++parent_pos, project);
} else {
}
else
{
// if has no parents: simply push to end of list
sorted.push_back (project);
}
Expand Down

0 comments on commit 32d14bc

Please sign in to comment.