Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[list] sort list reply alphabetically (Fixes #836) #994

Merged
merged 12 commits into from Sep 4, 2019
10 changes: 8 additions & 2 deletions include/multipass/cli/format_utils.h
Expand Up @@ -52,8 +52,14 @@ Instances multipass::format::sorted(const Instances& instances)

auto ret = instances;
const auto petenv_name = Settings::instance().get(petenv_key).toStdString();
std::partial_sort(std::begin(ret), std::next(std::begin(ret)), std::end(ret),
[&petenv_name](const auto& a, const auto& /*unused*/) { return a.name() == petenv_name; });
std::sort(std::begin(ret), std::end(ret), [&petenv_name](const auto& a, const auto& b) {
if (a.name() == petenv_name)
return true;
else if (b.name() == petenv_name)
return false;
else
return a.name() < b.name();
});

return ret;
}
Expand Down