PythiloLesson 5 of 12 · progress kept in this browser

Paginate through a stable composite order

Offset pagination can skip or repeat rows when preceding data changes. A keyset cursor identifies the last ordering key instead. When timestamps tie, a unique identifier must break ties or a page boundary can permanently lose rows.

The cursor contains both timestamp and identifier, and the next page uses a strict lexicographic comparison. This handles tied timestamps and insertions before the cursor. It is not a historical snapshot: a newly inserted row after the cursor may appear in a later page. Clients that need snapshot semantics must carry a snapshot boundary too.

rows=[(1,"a"),(1,"b"),(2,"c")]
cursor=(1,"a")
print([row for row in rows if row>cursor])
Your task

Implement page_after(rows,cursor,limit). rows are (timestamp,id) pairs in any order. Return sorted rows strictly greater than cursor, or from the beginning for None, at most limit. Require positive limit.