Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <script>
- function compare(a, b) {
- if (a.length > b.length)
- return 1;
- else if (a.length < b.length)
- return -1;
- else
- return 0;
- }
- function test() {
- document.getElementById("b").innerHTML = "";
- strs = document.getElementById("a").value.split(" ");
- strs.sort(compare);
- for (var i = 0; i < strs.length; ++ i) {
- document.getElementById("b").innerHTML += strs[i] + " ";
- }
- }
- </script>
- </head>
- <body>
- <input type="text" id="a">
- <button onclick="test()">Ввод</button>
- <p id="b"></p>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement