sort algorithm written in python