RemovePlan -> sort by name
MODIFY
include/vcpkg_Dependencies.h
include/vcpkg_Dependencies.h
@@ -67,6 +67,8 @@ namespace vcpkg::Dependencies
struct PackageSpecWithRemovePlan
{
+ static bool compare_by_name(const PackageSpecWithRemovePlan* left, const PackageSpecWithRemovePlan* right);
+
PackageSpecWithRemovePlan(const PackageSpec& spec, RemovePlanAction&& plan);
PackageSpec spec;

MODIFY
src/commands_remove.cpp
src/commands_remove.cpp
@@ -101,14 +101,6 @@ namespace vcpkg::Commands::Remove
write_update(paths, pkg);
}
- static void sort_packages_by_name(std::vector<const PackageSpecWithRemovePlan*>* packages)
- {
- std::sort(packages->begin(), packages->end(), [](const PackageSpecWithRemovePlan* left, const PackageSpecWithRemovePlan* right) -> bool
- {
- return left->spec.name() < right->spec.name();
- });
- }
-
static void print_plan(const std::vector<PackageSpecWithRemovePlan>& plan)
{
std::vector<const PackageSpecWithRemovePlan*> not_installed;
@@ -131,7 +123,7 @@ namespace vcpkg::Commands::Remove
if (!not_installed.empty())
{
- sort_packages_by_name(&not_installed);
+ std::sort(not_installed.begin(), not_installed.end(), &PackageSpecWithRemovePlan::compare_by_name);
System::println("The following packages are not installed, so not removed:\n%s",
Strings::join("\n ", not_installed, [](const PackageSpecWithRemovePlan* p)
{
@@ -141,7 +133,7 @@ namespace vcpkg::Commands::Remove
if (!remove.empty())
{
- sort_packages_by_name(&remove);
+ std::sort(remove.begin(), remove.end(), &PackageSpecWithRemovePlan::compare_by_name);
System::println("The following packages will be removed:\n%s",
Strings::join("\n", remove, [](const PackageSpecWithRemovePlan* p)
{

MODIFY
src/vcpkg_Dependencies.cpp
src/vcpkg_Dependencies.cpp
@@ -30,6 +30,11 @@ namespace vcpkg::Dependencies
{
}
+ bool PackageSpecWithRemovePlan::compare_by_name(const PackageSpecWithRemovePlan* left, const PackageSpecWithRemovePlan* right)
+ {
+ return left->spec.name() < right->spec.name();
+ }
+
PackageSpecWithRemovePlan::PackageSpecWithRemovePlan(const PackageSpec& spec, RemovePlanAction&& plan)
: spec(spec), plan(std::move(plan))
{

RemovePlan -> sort by name