We are currently using a home-spun bubble sort that had guaranteed time (return_count * N, where return count is very small). Now that we're allowing users to define return count, and they could potentially define it large, this implementation is bad.