summaryrefslogtreecommitdiff
path: root/Userland/Utilities
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-01-24 19:15:34 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-24 19:15:34 +0100
commitf8d643284e293978b4a612e901691fad17461d6e (patch)
treeeb6343eec243a58eefdec59fac13136acd464a3c /Userland/Utilities
parent7a71d4b887b22590ed99aaac64a74dcb0fd2900b (diff)
downloadserenity-f8d643284e293978b4a612e901691fad17461d6e.zip
pmap: Sort memory regions in output
This makes the program 100% nicer to use. :^)
Diffstat (limited to 'Userland/Utilities')
-rw-r--r--Userland/Utilities/pmap.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/Userland/Utilities/pmap.cpp b/Userland/Utilities/pmap.cpp
index 2706b3fc4a..d25edcb294 100644
--- a/Userland/Utilities/pmap.cpp
+++ b/Userland/Utilities/pmap.cpp
@@ -26,6 +26,7 @@
#include <AK/ByteBuffer.h>
#include <AK/JsonObject.h>
+#include <AK/QuickSort.h>
#include <AK/String.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/File.h>
@@ -70,7 +71,13 @@ int main(int argc, char** argv)
auto file_contents = file->read_all();
auto json = JsonValue::from_string(file_contents);
ASSERT(json.has_value());
- json.value().as_array().for_each([](auto& value) {
+
+ Vector<JsonValue> sorted_regions = json.value().as_array().values();
+ quick_sort(sorted_regions, [](auto& a, auto& b) {
+ return a.as_object().get("address").to_u32() < b.as_object().get("address").to_u32();
+ });
+
+ for (auto& value : sorted_regions) {
auto map = value.as_object();
auto address = map.get("address").to_int();
auto size = map.get("size").to_string();
@@ -100,7 +107,7 @@ int main(int argc, char** argv)
auto name = map.get("name").to_string();
printf("%-20s ", name.characters());
printf("\n");
- });
+ }
return 0;
}