bring sort down into python for speed.