add sorting python code