-
I have an name: foo
channels:
- pytorch
- conda-forge
- bioconda
dependencies:
- pybigwig=0.3.18
- cpuonly=2.0
- mkl_random=1.2.0
- mkl_fft=1.2.0
- ucsc-bigbedtobed=377
- certifi=2021.5.30
- pip=21.2.4
- torchvision=0.11.3
- cudnn=7.6.5.32
- pytorch-cpu=1.1.0
- python=3.6.15
- pip:
- -r requirements.txt I'd like to sort the I'm running yq version 4.26.1 installed with snap on linux. The best I've managed is cat environment.yml | yq '.dependencies | sort_keys(.)' but this doesn't seem to sort the array
(In addition, not sure how I'd put the sorted array back into the file). Any help would be appreciated, thanks! Kind regards, Ramon. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Other things I've tried, but give syntax errors:
|
Beta Was this translation helpful? Give feedback.
-
This is a little trickier than examples I have in the docs, because in that array of strings there is a single map entry What needs to be done is to use the Solving this actually revealed a bug in the alternative (//) operator in
Explanation:
|
Beta Was this translation helpful? Give feedback.
This is a little trickier than examples I have in the docs, because in that array of strings there is a single map entry
pip: ...
- so the vanilla sort will complain about not knowing how to sort a map ( sort only works for scalars, got !!map)What needs to be done is to use the
sort_by
operator to specify how to sort this array - particularly when it encounters a map.Solving this actually revealed a bug in the alternative (//) operator in
yq
! I've made a new release v4.27.4 - so you will need that version for this:Explanation:
|=