diff --git a/sort.js b/sort.js new file mode 100644 index 0000000..b23ba19 --- /dev/null +++ b/sort.js @@ -0,0 +1,33 @@ +/*jslint plusplus: true */ +/*jslint browser: true, devel: true */ +function showElem() { + "use strict"; + var myform, + vseg = myform.elements[0].value, + mass = [], + temp = vseg.split(' '), + j = 0, + i = 0, + num_one, + num_two, + max; + for (j = 0; j <= (temp.length - 1); j++) { + for (i = 0; i <= (temp.length - 1); i++) { + num_one = +temp[i]; + num_two = +temp[i + 1]; + if (num_one <= num_two) { + max = num_two; + temp[i] = num_one; + temp[i + 1] = max; + } + if (num_one > num_two) { + max = num_one; + temp[i] = num_two; + temp[i + 1] = max; + } + } + } + for (i = 0; i <= (temp.length - 1); i++) { + document.body.innerHTML = temp[i]; + } +} \ No newline at end of file