@@ -5082,10 +5082,16 @@ def sort(self, axis= -1, kind='quicksort', order=None,
5082
5082
filler = maximum_fill_value (self )
5083
5083
else :
5084
5084
filler = fill_value
5085
- idx = np .meshgrid (* [np .arange (x ) for x in self .shape ], sparse = True ,
5086
- indexing = 'ij' )
5087
- idx [axis ] = self .filled (filler ).argsort (axis = axis , kind = kind ,
5088
- order = order )
5085
+
5086
+ sidx = self .filled (filler ).argsort (axis = axis , kind = kind ,
5087
+ order = order )
5088
+ # save meshgrid memory for 1d arrays
5089
+ if self .ndim == 1 :
5090
+ idx = sidx
5091
+ else :
5092
+ idx = np .meshgrid (* [np .arange (x ) for x in self .shape ], sparse = True ,
5093
+ indexing = 'ij' )
5094
+ idx [axis ] = sidx
5089
5095
tmp_mask = self ._mask [idx ].flat
5090
5096
tmp_data = self ._data [idx ].flat
5091
5097
self ._data .flat = tmp_data
@@ -6187,10 +6193,16 @@ def sort(a, axis= -1, kind='quicksort', order=None, endwith=True, fill_value=Non
6187
6193
filler = maximum_fill_value (a )
6188
6194
else :
6189
6195
filler = fill_value
6190
- # return
6191
- indx = np .meshgrid (* [np .arange (x ) for x in a .shape ], sparse = True ,
6192
- indexing = 'ij' )
6193
- indx [axis ] = filled (a , filler ).argsort (axis = axis , kind = kind , order = order )
6196
+
6197
+ sindx = filled (a , filler ).argsort (axis = axis , kind = kind , order = order )
6198
+
6199
+ # save meshgrid memory for 1d arrays
6200
+ if a .ndim == 1 :
6201
+ indx = sindx
6202
+ else :
6203
+ indx = np .meshgrid (* [np .arange (x ) for x in a .shape ], sparse = True ,
6204
+ indexing = 'ij' )
6205
+ indx [axis ] = sindx
6194
6206
return a [indx ]
6195
6207
sort .__doc__ = MaskedArray .sort .__doc__
6196
6208
0 commit comments