data-8/datascience

.sort(, descending=True) is not a stable sort

Closed this issue · 2 comments

.sort('X') uses a stable sort: in the case of ties in column X, it preserves the existing order of the rows.

.sort('X', descending=True) is not a stable sort: in case of ties, it reverses the order of the rows. It appears to be behave as though we did .sort('X') and then reversed the order of the rows.

This is a bit surprising and counter-intuitive. Is it intentional? Is there an argument for why this behavior is better than the alternative of making descending=True also use a stable sort?

I can take a closer look at this.