Sort functions properly.