-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask-6.html
More file actions
43 lines (43 loc) · 1.15 KB
/
Task-6.html
File metadata and controls
43 lines (43 loc) · 1.15 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<html>
<head>
<title></title>
</head>
<body>
<form onclick="return f1()">
<input type="text" id="str" placeholder="Enter a String" >
<input type="submit">
</form>
<p id="a1"></p>
<script>
function f1(){
a=document.getElementById('str').value;
let l=a.length;
var arr=[];
for(let i=0;i<l;i++)
{
arr[i]=a.charCodeAt(i);
}
for(let i = 0; i < l; i++) {
let min = i;
for(let j = i+1; j < l; j++){
if(arr[j] < arr[min]) {
min=j;
}
}
if (min != i) {
let tmp = arr[i];
arr[i] = arr[min];
arr[min] = tmp;
}
}
let b=[];
for(let i=0;i<l;i++)
{
b[i]=String.fromCharCode(arr[i]);
}
document.getElementById('a1').innerHTML=b;
return false;
}
</script>
</body>
</html>