-
-
Notifications
You must be signed in to change notification settings - Fork 625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sort broken for date #1412
Comments
Yep that's a bug - I haven't added support for dates/timestamps in sort - will fix in next release! |
Love to hear it. Note that the issue also occurs when converting the date to a string before sorting. That is a reliable workaround when using yymmdd because you effectively sort by number. Any idea why that is? |
Yep, that transforms it to an integer, which will sort correctly 👍🏼 |
If you look at my command 2/3, when we just have integers in a string, it does not sort correctly also. |
I can't replicate that :/
Note that the style parameter does not affect the value for sorting:
|
Good to know. May circle back on this if troubleshooting yields something relevant. |
Just coming back to this to let you know that v4.30.4 has fixed the problem for me. |
Describe the bug
I am trying to sort by a dictionary by a value that contains numbers. The sorting does not work, regardless of whether I use the value as-is or convert it to string.
Version of yq: 4.29.2
Operating system: linux
Installed via: snap
Input
I tried the following:
Command 1
Output 1
Command 2
yq '[.[] | .date style="double"] | sort_by(.date)' input.yaml
Output 2
Command 3
yq '[.[] | .date style="double"] |= sort_by(.date)' input.yaml
Expected behavior
Additional context
Looks like for some reason yq is reversing the order of the list. Except for the third command that is. I have no idea what is going on, but certainly is not expected behavior.
The text was updated successfully, but these errors were encountered: