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/4027#issuecomment-624652995,https://api.github.com/repos/pydata/xarray/issues/4027,624652995,MDEyOklzc3VlQ29tbWVudDYyNDY1Mjk5NQ==,408363,2020-05-06T13:34:49Z,2020-05-06T13:34:49Z,NONE,It looks like this is fixed by 1eedc5c,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,611879581 https://github.com/pydata/xarray/issues/4027#issuecomment-624623472,https://api.github.com/repos/pydata/xarray/issues/4027,624623472,MDEyOklzc3VlQ29tbWVudDYyNDYyMzQ3Mg==,408363,2020-05-06T12:36:55Z,2020-05-06T12:36:55Z,NONE,"Indeed, if I change [this line](https://github.com/pydata/xarray/blob/master/xarray/core/dataset.py#L4618) from ``` obj[dim] = (dim, lev) ``` to ``` obj[dim] = (dim, sorted(lev)) ``` then this particular case works: ``` Original Series row column -1 -3 0 -4 1 -2 -3 2 -4 3 dtype: int32 After going to DataArray and back row column -2 -4 3 -3 2 -1 -4 1 -3 0 dtype: int32 ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,611879581 https://github.com/pydata/xarray/issues/4027#issuecomment-624621313,https://api.github.com/repos/pydata/xarray/issues/4027,624621313,MDEyOklzc3VlQ29tbWVudDYyNDYyMTMxMw==,408363,2020-05-06T12:32:13Z,2020-05-06T12:32:13Z,NONE,"It looks like the following line causes the input data to be reordered, so it no longer matches the original dimensions: https://github.com/pydata/xarray/blob/master/xarray/core/dataset.py#L4564 This would probably work if the dimensions were sorted before putting them into the dataset.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,611879581 https://github.com/pydata/xarray/issues/4027#issuecomment-624613640,https://api.github.com/repos/pydata/xarray/issues/4027,624613640,MDEyOklzc3VlQ29tbWVudDYyNDYxMzY0MA==,408363,2020-05-06T12:14:47Z,2020-05-06T12:14:47Z,NONE,"Simpler example, if it's any use: ``` df = pd.DataFrame(np.arange(4).reshape((2,2)), index=[-1,-2], columns=[-3,-4]) df.index.name, df.columns.name = 'row', 'column' print('Original Series') print(df.stack()) print('After going to DataArray and back') print(df.stack().to_xarray().to_series()) ``` Output ``` Original Series row column -1 -3 0 -4 1 -2 -3 2 -4 3 dtype: int32 After going to DataArray and back row column -1 -3 3 -4 2 -2 -3 1 -4 0 dtype: int32 ```","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,611879581