fork(1) download
  1. importPackage(java.io);
  2. importPackage(java.lang);
  3.  
  4. function isNumber(a) {
  5. return !isNaN(+a);
  6. }
  7.  
  8. function swap(arr, i, j) {
  9. [arr[i], arr[j]] = [arr[j], arr[i]];
  10. }
  11.  
  12. function sort(str, i = 0, j = 1) {
  13. let res = [...str];
  14.  
  15. for (let i = 0; i < str.length - 1; i++) {
  16. if (!isNumber(res[i])) continue;
  17. for (let j = i + 1; j < str.length; j++) {
  18. if (!isNumber(res[j])) continue;
  19. if (res[i] > res[j]) {
  20. swap(res, i, j);
  21. }
  22. }
  23. }
  24.  
  25. return res.join("");
  26. }
  27.  
  28. let str = "a12j305f20a";
  29. let str_ = sort(str);
  30. console.log(str_);
  31.  
Runtime error #stdin #stdout #stderr 0.18s 2313728KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
js: "prog.js", line 12: missing ) after formal parameters
js: function sort(str, i = 0, j = 1) {
js: ......................^
js: "prog.js", line 1: Compilation produced 1 syntax errors.