We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e051eac commit 6f02d24Copy full SHA for 6f02d24
algorithms/sorting/permutationSort.m
@@ -0,0 +1,13 @@
1
+function list = permutationSort(list)
2
+
3
+ permutations = perms(1:numel(list)); %Generate all permutations of the item indicies
4
5
+ %Test every permutation of the indicies of the original list
6
+ for i = (1:size(permutations,1))
7
+ if issorted( list(permutations(i,:)) )
8
+ list = list(permutations(i,:));
9
+ return %Once the correct permutation of the original list is found break out of the program
10
+ end
11
12
13
+end
0 commit comments