Sort /etc/passwd by the 3rd field of each line numerically, using ":" as a field separator

sort

sort --field-separator={{:}} --key={{3n}} {{/etc/passwd}}

click the source code to copy install sort on any operating system with command-not-found.com