Sort .gitmodules, also easily adaptable to sort files in blocks (e.g. 4 lines at a time, or arbitrary region at a time).
See also:
#!/usr/bin/env bash
awk 'BEGIN { I=0 ; J=0 ; K="" } ; /^\[submodule/{ N+=1 ; J=1 ; K=$2 ; gsub(/("vendor\/|["\]])/, "", K) } ; { print K, N, J, $0 } ; { J+=1 }' .gitmodules \
| sort \
| awk '{ $1="" ; $2="" ; $3="" ; print }' \
| sed 's/^ *//g' \
| awk '/^\[/{ print ; next } { print "\t", $0 }' \
> .gitmodules
@4U6U57 Switched the pipe with sponge.
I also fixed an annoyance that it would add an extra space after the tab character by removing the comma.