Merge "Sort devices list before output."
am: 18cdd3502a
Change-Id: I8c8bee720224e7c774a58421022f87fea4839f4a
diff --git a/adb/transport.cpp b/adb/transport.cpp
index 5cf2450..f221785 100644
--- a/adb/transport.cpp
+++ b/adb/transport.cpp
@@ -952,10 +952,18 @@
}
std::string list_transports(bool long_listing) {
- std::string result;
-
std::lock_guard<std::recursive_mutex> lock(transport_lock);
- for (const auto& t : transport_list) {
+
+ auto sorted_transport_list = transport_list;
+ sorted_transport_list.sort([](atransport*& x, atransport*& y) {
+ if (x->type != y->type) {
+ return x->type < y->type;
+ }
+ return strcmp(x->serial, y->serial) < 0;
+ });
+
+ std::string result;
+ for (const auto& t : sorted_transport_list) {
append_transport(t, &result, long_listing);
}
return result;