<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> </head> <body> <script type="text/javascript"> Array.prototype.selection_sort = function(){ var i, j, min, temp; for (i = 0; i < this.length - 1; i++) {
min = i;
for (j = i + 1; j < this.length; j++) {
if(this[min] > this[j]){
min = j;
}
temp = this[min];
this[min] = this[i];
this[i] = temp;
};
}; return this; } var num = [7, 3, 2, 100, 5, 4, 0]; num.selection_sort(); for (var i = 0; i < num.length; i++) document.body.innerHTML += num[i] + " "; </script> </body> </html>
相关文章
- 07-12Collections中的ddAll,binarySearch,copy,sort,fill,frequency,indexOfSubList,replaceAll,reverse方法
- 07-12LeetCode-561. Array Partition I(Quick Sort快速排序)
- 07-12vs2010下sort比较函数链接错误问题
- 07-12Hadoop-2.2.0中文文档—— MapReduce下一代- 可插入的 Shuffle 和 Sort
- 07-12Leetcode#148 Sort List
- 07-122016 Multi-University Training Contest 4 Bubble Sort(树状数组模板)
- 07-12tensorflow(十四):张量排序( Sort/argsort, Topk, Top-5 Acc.)
- 07-12LeeCode-Insertion Sort List
- 07-12Sort a linked list in O(n log n) time using constant space complexity.
- 07-12【题解】P3149 排序 & test10.27 T1 sort