html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/issues/1635#issuecomment-545261919,https://api.github.com/repos/pydata/xarray/issues/1635,545261919,MDEyOklzc3VlQ29tbWVudDU0NTI2MTkxOQ==,7441788,2019-10-23T04:35:37Z,2019-10-23T04:35:37Z,CONTRIBUTOR,I think this issue is still relevant.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,266133430
https://github.com/pydata/xarray/issues/1635#issuecomment-337672616,https://api.github.com/repos/pydata/xarray/issues/1635,337672616,MDEyOklzc3VlQ29tbWVudDMzNzY3MjYxNg==,7441788,2017-10-18T17:48:28Z,2017-10-18T18:36:25Z,CONTRIBUTOR,"I'm not a fan of auto-flattening either, but that's what `nd.argsort()` does...
One option is to have `DataArray.arg{min,max,sort}()` all take an optional flag argument specifying whether to return integer indices or index labels. But I think my preference would be be to have six separate functions: `DataArray.{idx,}arg{min,max,sort}()` (or some such nomenclature that includes `arg` in all six functions).","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,266133430
https://github.com/pydata/xarray/issues/1635#issuecomment-337623613,https://api.github.com/repos/pydata/xarray/issues/1635,337623613,MDEyOklzc3VlQ29tbWVudDMzNzYyMzYxMw==,7441788,2017-10-18T15:08:57Z,2017-10-18T15:08:57Z,CONTRIBUTOR,"I think that makes sense, though I don't quite understand what would go in its place. Another possibility -- perhaps a bad one -- is to permute the values in the sorted dimension so that they match the resulting values (i.e. something like `result.coords[dim] = np.take(da.coords[dim].values, result.values, axis=axis)`).
Note that `ndarray.argsort(axis=None)` sorts the flattened array, so the returned `DataArray` should respect this
Alternative suggestion: have `DataArray.argsort()` return an `ndarray` filled with labels from the sorted dimension, i.e. something like:
```
class DataArray:
def argsort(self, **kwargs):
# TODO: update kwargs['axis'] based 'axis' and 'dim', and remove 'dim'
if kwargs['axis'] is None:
kwargs['axis'] = -1
return self.stack(dim=self.dims).argsort(**kwargs)
return np.take(self.coords[self.dims[kwargs['axis']].values, self.values.argsort(**kwargs))
```
BTW, I'm just thinking in terms of `ndarray`s. Someone more knowledgeable than me may want to consider how to make it work intelligently with dask.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,266133430