Permalink
Browse files

Update sort.cpp

  • Loading branch information...
pbeckingham committed Feb 7, 2019
1 parent 803f4a5 commit 32d14bc085c563ffd1ad7359758bd5909ac7e635
Showing with 7 additions and 6 deletions.
  1. +7 −6 src/sort.cpp
@@ -49,7 +49,6 @@ void sort_tasks (
const std::string& keys)
{
Timer timer;

global_data = &data;

// Split the key defs.
@@ -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);
}

0 comments on commit 32d14bc

Please sign in to comment.