1//HTML
2<input type='file' accept='image/*' onchange='openFile(event)'><br>
3<img id='output'>
4
5//Javascript
6var openFile = function(event) {
7 var input = event.target;
8
9 var reader = new FileReader();
10 reader.onload = function(){
11 var dataURL = reader.result;
12 var output = document.getElementById('output');
13 output.src = dataURL;
14 };
15 reader.readAsDataURL(input.files[0]);
16}
1function selection_sort(data)
2{
3 for(let i = 0; i < data.length - 2; i++)
4 {
5 // Finding the smallest number in the subarray
6 let min = i;
7 for(let j = i+1; j < data.length; j++)
8 {
9 if(data[j] < data[min])
10 {
11 min = j;
12 }
13 }
14 swap_positions(data, i, min);
15 }
16 return data;
17}
18
19function swap_positions(data1, left, right)
20{
21 backup_old_data_right_value = data1[right];
22 data1[right] = data1[left];
23 data1[left] = backup_old_data_right_value;
24 return data1;
25}
26
27let arr = [6, 9, 10, 5, 7, 11, 13, 3, 14, 12];
28selection_sort(arr);
29document.write(arr);