jQuery's function $(function())’s execute order when the $(function()) called more one times
<p>Code like this：</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>$(window.document).ready(function () {
    window.alert('alert 1');
});

$(function () {
    window.alert('alert 2');
});

$(function () {
   window.alert('alert 3');
});</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;title&gt;Demo2&lt;/title&gt;
    &lt;script src="jquery-3.1.1.js"&gt;&lt;/script&gt;
    &lt;script src="demo2.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;/body&gt;
&lt;/html&gt;</code></pre>
</div>
</div>
</p>

<p>when i execute the above code, the page' alert order sometimes is:
alert 1, alert 2, alert 3, and sometimes is: alert 1, alert 3, alert 2.
could anyone tell my why?</p>