Closed
Description
searchsorted
requires that the searched object is (monotonically) sorted to produce correct results. Orderedness is neither a necessary or sufficient condition to make searchsorted work correctly.
Categorical.searchsorted
has a hard check for if the Categorical is ordered:
pandas/pandas/core/arrays/categorical.py
Lines 1382 to 1388 in e0f978d
This is too strict, as unordered but sorted Categoricals could also benefit from using searchsorted.
I propose removing this check and (like for non-categoricals) let the user have the responsibility to ensure that the Categorical is sorted correctly. This would allow very quick lookups in all sorted Categoricals, whether they're ordered or not.