in vim:
%s/$/<some char that's not in the file, to use as an EOL marker, e.g. '%'>/
cursor to the first bibtex entry (at the @)
start recording q
Visual line mode
/^}%$
Shift+J
escape
down one line
stop recording
for each subsequenty entry, playback q
when all entries on one line each, sort the file with
sort /{/
then replace EOL marker with Ctrl+V return
un-indent the entire file
remove blank lines with g/^$/d