This takes about 4–8 seconds on my machine
npx has to first download the package.
If that's too slow for you,
install the package globally:
# i = install
# -g = --global
npm i -g sort-package-json
Then you can run just:
And it will take less than a second.
Source: My own Stack Overflow answer