def _get_codes_for_sorting(self):
from pandas.core.arrays import Categorical<EOL>def cats(level_codes):<EOL><INDENT>return np.arange(np.array(level_codes).max() + <NUM_LIT:1> if<EOL>len(level_codes) else <NUM_LIT:0>,<EOL>dtype=level_codes.dtype)<EOL><DEDENT>return [Categorical.from_codes(level_codes, cats(level_codes),<EOL>ordered=True)<EOL>for level_codes in self.codes]<EOL>
we categorizing our codes by using the
available categories (all, not just observed)
excluding any missing ones (-1); this is in preparation
for sorting, where we need to disambiguate that -1 is not
a valid valid