var temp = [4, 6, 78, 9, 0, 1, 4, 8, 34, 78, 08] var min = null; var t = null; for(i=0;i<temp.length - 1;i++) { min = temp[i]; for (j = i+1; j < temp.length; j++) { if (min > temp[j]) { t = min; min = temp[j]; temp[j] = t; } } temp[i] = min; } console.info(temp); console.info('end info.....')