Description
What happened:
A KeyError is thrown when supplying a tuple of dimensions to DataArray.sortby()
What you expected to happen:
The dataarray to be sorted according to the dimensions.
Minimal Complete Verifiable Example:
import xarray as xr
import numpy as np
da=xr.DataArray(np.random.rand(3,3), coords=(('x', range(3, 0, -1)), ('y', range(3, 0, -1))))
da.sortby(da.dims)
Anything else we need to know?:
If the tuple is cast to a list it works correctly:
da.sortby(list(da.dims))
Environment:
Output of xr.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.12 (default, Nov 11 2020, 22:22:08)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.4)]
python-bits: 64
OS: Darwin
OS-release: 18.7.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: None
LOCALE: en_US.UTF-8
libhdf5: None
libnetcdf: None
xarray: 0.16.2
pandas: 1.1.4
numpy: 1.19.4
scipy: 1.5.4
netCDF4: None
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: None
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: 1.3.2
dask: 2020.12.0
distributed: None
matplotlib: 3.3.3
cartopy: None
seaborn: None
numbagg: None
pint: None
setuptools: 50.3.2
pip: 20.3.3
conda: None
pytest: 6.2.1
IPython: 7.16.1
sphinx: None