Skip to content

Instantly share code, notes, and snippets.

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;
@hxlniada
hxlniada / permutation
Last active December 23, 2015 11:29
数组全排序
/*******************
* javascript
*第一种方式实现全排序
*******************
*/
var result = [];
function permutation1(arr) {
perm1(arr, 0);
document.write(result.join('<br />'));