Added ability to sort properties before encoding