Commit 9f6d03b3 authored by Sasha Goldshtein's avatar Sasha Goldshtein

ustat: Sort by pid if no other sort column provided

parent bee71b2d
...@@ -232,6 +232,8 @@ class Tool(object): ...@@ -232,6 +232,8 @@ class Tool(object):
if self.args.sort: if self.args.sort:
counts = sorted(counts.items(), key=lambda (_, v): counts = sorted(counts.items(), key=lambda (_, v):
-v.get(self.args.sort.upper(), 0)) -v.get(self.args.sort.upper(), 0))
else:
counts = sorted(counts.items(), key=lambda (k, _): k)
for pid, stats in counts: for pid, stats in counts:
print("%-6s %-16s %-10d %-6d %-10d %-8d %-8d %-10d" % ( print("%-6s %-16s %-10d %-6d %-10d %-8d %-8d %-10d" % (
pid, targets[pid][0:16], pid, targets[pid][0:16],
...@@ -262,4 +264,7 @@ class Tool(object): ...@@ -262,4 +264,7 @@ class Tool(object):
exit() exit()
if __name__ == "__main__": if __name__ == "__main__":
try:
Tool().run() Tool().run()
except KeyboardInterrupt:
pass
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment