This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function iterSort(arr) { | |
var result = [], len = arr.length; | |
arr.sort(); | |
result.push(arr.join('')); | |
while (true) { | |
var temp; | |
for (var i = len - 1; i >= 1; i--) { | |
if (arr[i] > arr[i - 1]) { | |
console.log(i, arr[i], arr[i - 1], arr.toString()); | |
temp = i - 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************* | |
* javascript | |
*第一种方式实现全排序 | |
******************* | |
*/ | |
var result = []; | |
function permutation1(arr) { | |
perm1(arr, 0); | |
document.write(result.join('<br />')); |