emit fields in increasing field order when possible

According to the Protocol Buffers documentation
(https://developers.google.com/protocol-buffers/docs/encoding#order),
fields should be written in field order when possible. The C++, Java and
Python PB libraries already do this. Change the Erlang code to do the same.