 <p>You could achieve this by looping over the properties of the object itself and sorting the arrays they contain, something like this:</p> <pre><code>for (var key in mainarray) { if (mainarray[key] === Array) mainarray[key].sort(); } </code></pre> <p><a href="https://jsfiddle.net/26gk4h9b/" rel="nofollow"><strong>Working example</strong></a></p> <p>Note that by default <code>sort()</code> only uses basic alphanumeric sorting logic. If you need anything more complex you would need to implement that yourself.</p>