a common algorithm, using quick sort, but time exceed