python sort is really slow