Apply quick sort algorithm (#738)