The function uses only three parameters: the criteria range, the reverse sort toggle, and the upper limit on rows of results.
Note that conditional formatting is applied using the PyXLL formatter option.
Hint: it isn’t the programming.
Using PyXLL, I have programmed automatic shapes in Excel. That is, I built a function that draws an arbitrary shape in a user spreadsheet: the shape is defined by a range of coordinates; as the coordinates are edited, a new shape can be drawn.