Skip to content

Instantly share code, notes, and snippets.

@beall49
Created August 20, 2015 04:40
Show Gist options
  • Select an option

  • Save beall49/135b2b79aa3da576ec43 to your computer and use it in GitHub Desktop.

Select an option

Save beall49/135b2b79aa3da576ec43 to your computer and use it in GitHub Desktop.
$('#btnSubmit').on('click',
function(){
var finalWords = [];
var txt = $("#txtInput").val().replace(/ /g,'');
var words = txt.split(",");
var newWords = words.sort();
for(x in newWords){
var str = newWords[x];
if (x>0){
str = " " + str
}
finalWords.push(str);
}
$("#txtInput").val(finalWords);
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment