Return to Snippet

Revision: 4605
at January 13, 2008 13:16 by darkphotn


Initial Code
<html>
<head><title>Javascript Sort</title</head>
<body>

<script language="javascript">
function generate(s){
  var temp = new Array();
  temp = s.split('\n');
  temp.sort();
  var result = "";
  var i;
  for(i=0; i<temp.length; i++) {
      result += temp[i] + "\n";
  }
  return result;
}

</script>

<form name="myform">
<textarea name="mytext" rows=20 cols=60>
Insert lines to sort here.
</textarea>
<br><br>
<input type="button" value="Sort!" onClick="javascript: document.myform.mytext.value = generate(document.myform.mytext.value);"><br><br>
</form>



</body>
</html>

Initial URL

                                

Initial Description

                                

Initial Title
Sort text in Javascript

Initial Tags

                                

Initial Language
JavaScript