fix os.write and sort

fix two compatibility issues in lang_php.py