@@ -5074,10 +5074,16 @@ def sort(self, axis= -1, kind='quicksort', order=None,
5074
5074
filler = maximum_fill_value (self )
5075
5075
else :
5076
5076
filler = fill_value
5077
- idx = np .meshgrid (* [np .arange (x ) for x in self .shape ], sparse = True ,
5078
- indexing = 'ij' )
5079
- idx [axis ] = self .filled (filler ).argsort (axis = axis , kind = kind ,
5080
- order = order )
5077
+
5078
+ sidx = self .filled (filler ).argsort (axis = axis , kind = kind ,
5079
+ order = order )
5080
+ # save meshgrid memory for 1d arrays
5081
+ if self .ndim == 1 :
5082
+ idx = sidx
5083
+ else :
5084
+ idx = np .meshgrid (* [np .arange (x ) for x in self .shape ], sparse = True ,
5085
+ indexing = 'ij' )
5086
+ idx [axis ] = sidx
5081
5087
tmp_mask = self ._mask [idx ].flat
5082
5088
tmp_data = self ._data [idx ].flat
5083
5089
self ._data .flat = tmp_data
@@ -6178,10 +6184,16 @@ def sort(a, axis= -1, kind='quicksort', order=None, endwith=True, fill_value=Non
6178
6184
filler = maximum_fill_value (a )
6179
6185
else :
6180
6186
filler = fill_value
6181
- # return
6182
- indx = np .meshgrid (* [np .arange (x ) for x in a .shape ], sparse = True ,
6183
- indexing = 'ij' )
6184
- indx [axis ] = filled (a , filler ).argsort (axis = axis , kind = kind , order = order )
6187
+
6188
+ sindx = filled (a , filler ).argsort (axis = axis , kind = kind , order = order )
6189
+
6190
+ # save meshgrid memory for 1d arrays
6191
+ if a .ndim == 1 :
6192
+ indx = sindx
6193
+ else :
6194
+ indx = np .meshgrid (* [np .arange (x ) for x in a .shape ], sparse = True ,
6195
+ indexing = 'ij' )
6196
+ indx [axis ] = sindx
6185
6197
return a [indx ]
6186
6198
sort .__doc__ = MaskedArray .sort .__doc__
6187
6199
0 commit comments