Updated py3 sort fix

@pradyun:  Suggested modification to your PR #176.