npx sort-dependencies <path-to-package-dir-or-package.json> --apply
The problem arises when tools like
pnpm publish in combination with rush then sort the dependencies alphabetically but don't commit it back leaving a dirty repo which causes
pnpm to abort publishing.
sort-dependencies is thus useful in
I also could somehow not find another package that did this the way I liked. prettier-package-json was close but did way more and also reordered the the root properties themselves which I did not like.