fix packet reorder python code