Finding the largest word in the given String
Before I give you my answer, a bit of critique regarding your code:


Naming convention in JS use camelCase.
What is sen? By itself, it doesn't tell me what it is. Name your variables meaningfully, one that tells you what it does the first time you read it.
Be consistent with whitespace. Usually, there should be spaces before and after operators (ie. a = b, foo = [] etc.)
Indention. Always have proper indention.
By sorting, you already fail the criteria of "first longest word prevails" because of sort instability.


You can simply use reduce. Carry around the longest word through the array, replacing it when you find something longer.



function findLongestWord(sentence) {
  return sentence.split(' ').reduce(function(longestWord, word){
    return word.length &gt; longestWord.length ? word : longestWord;
  });
}

var str = "The quick brown fox jumps over the lazy dog";

document.write(findLongestWord(str));