- Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathSelectSort.html
More file actions
Latest commit
29 lines (26 loc) · 604 Bytes
/
Copy pathSelectSort.html
File metadata and controls
29 lines (26 loc) · 604 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!DOCTYPE html>
<htmllang="en">
<head>
<metacharset="UTF-8">
<title>Title</title>
<scriptsrc="SortTestHelper.js"></script>
</head>
<body>
<script>
functionselectSort(arr){
letlen=arr.length;
for(leti=0;i<len;i++){
letminIndex=i;
for(letj=i+1;j<len;j++){
if(arr[j]<arr[minIndex]){
minIndex=j
}
}
swap(arr,i,minIndex)
}
console.log(arr)
}
selectSort([3,10,5,7,2,4,9,6,1,8])
</script>
</body>
</html>