Skip to content

Commit

Permalink
Improve activities.sorted() doctest
Browse files Browse the repository at this point in the history
  • Loading branch information
dlax committed Jun 9, 2022
1 parent 403565a commit cfc6e42
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pgactivity/activities.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,11 @@ def sorted(processes: List[T], *, key: SortKey, reverse: bool = False) -> List[T
>>> [p.pid for p in processes]
['6228', '6239', '6240']
>>> processes = sorted(processes, key=SortKey.mem)
>>> [p.pid for p in processes]
>>> [(p.pid, p.duration) for p in processes]
['6240', '6239', '6228']
>>> processes = sorted(processes, key=SortKey.duration, reverse=True) # sort by duration + pid asc
When using the 'duration' sort key, processes are also sorted by ascending PID:
>>> processes = sorted(processes, key=SortKey.duration, reverse=True)
>>> [p.pid for p in processes]
['6239', '6240', '6228']
"""
Expand Down

0 comments on commit cfc6e42

Please sign in to comment.