Sorting algorithms/Permutation sort: Difference between revisions

m
Line 433:
 
=={{header|Groovy}}==
Permutation sort is an astonishingly inefficient sort algorithm. To even begin to make it tractable, we need to be able to create enumerated permutations on the fly, rather than relying on [[Groovy]]'s ''List.permutations()'' method. For a list of length ''N'' there are ''N!'' permutations. In this solution, ''makePermutation'' creates the ''I<sup>th</sup>'' permutation to order based on a recursive construction of a unique indexindexed permutation. The sort method then checks to see if that permutation is sorted, and stops when it is.
 
I believe that this method of constructing permutations results in a stable sort, but I have not actually proven that assertion.
Anonymous user