Array sort method unexpected behavior : <p>I have an array having values are <strong>1,10,6,8,7</strong> and I want to sort this using <code>sort()</code> method, It's giving result like this <strong>1,10,6,7,8</strong> rather than <strong>1,6,7,8,10</strong></p>

<p><em>I wrote code below :</em></p>

<pre><code>var arr = [1,10,6,8,7];
arr.sort();
document.write(arr);
</code></pre>

<p><a href="https://i.stack.imgur.com/uHL9l.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uHL9l.jpg" alt="Snap code"></a></p>

<p>Can anyone have idea about this?</p>
