Skip to content

Commit

Permalink
ustat: Sort by pid if no other sort column provided
Browse files Browse the repository at this point in the history
  • Loading branch information
goldshtn committed Dec 19, 2016
1 parent bee71b2 commit 9f6d03b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tools/ustat.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ def _loop_iter(self):
if self.args.sort:
counts = sorted(counts.items(), key=lambda (_, v):
-v.get(self.args.sort.upper(), 0))
else:
counts = sorted(counts.items(), key=lambda (k, _): k)
for pid, stats in counts:
print("%-6s %-16s %-10d %-6d %-10d %-8d %-8d %-10d" % (
pid, targets[pid][0:16],
Expand Down Expand Up @@ -262,4 +264,7 @@ def run(self):
exit()

if __name__ == "__main__":
Tool().run()
try:
Tool().run()
except KeyboardInterrupt:
pass

0 comments on commit 9f6d03b

Please sign in to comment.