Porting of Sorting to the python 3