通过一趟排序将待排序记录分割成独立的两部分,其中一部分记录的关键字均比另一部分的关键字小,则可分别对着两部分记录分别进行排序,已达到整个序列有序的目的。
以下是地铁上花一个小时默写的算法实现,在php中测试排序18万的数据需要1.3秒,但使用sort()函数只需要0.045秒,差距依然很大,还有很大待优化空间。