diff --git a/pandas/core/indexes/datetimelike.py b/pandas/core/indexes/datetimelike.py index b41227871ae03b..9dcf62d4724817 100644 --- a/pandas/core/indexes/datetimelike.py +++ b/pandas/core/indexes/datetimelike.py @@ -284,7 +284,10 @@ def sort_values(self, return_indexer=False, ascending=True): sorted_index = self.take(_as) return sorted_index, _as else: - sorted_values = np.sort(self._ndarray_values) + # NB: using asi8 instead of _ndarray_values matters in numpy 1.18 + # because the treatment of NaT has been changed to put NaT last + # instead of first. + sorted_values = np.sort(self.asi8) attribs = self._get_attributes_dict() freq = attribs["freq"]