larcenists / larceny

Larceny Scheme implementation
Other
203 stars 32 forks source link

Implemented (r6rs sorting) for R7RS systems. #729

Closed TaylanUB closed 9 years ago

TaylanUB commented 9 years ago

Fairly straightforward merge sort for non-mutating and quicksort for mutating/in-place sort.

Non-mutating vector sort is specified to not mutate the return values of previous returns in case of multiple returns, so we do vector->list + merge sort + list->vector instead of copying & in-place sorting.

Quicksort handles repeated elements but is otherwise fairly simplistic (always chooses middle index as the pivot, doesn't use insertion sort).