Sorting Array of Arrays having variable number of elements <p>I have to sort an array of arrays. I've searched for solutions however my problem is: </p> <ol> <li>need to sort arrays that may have different sizes from a script run to another. </li> <li>need to sort not only by one or two elements, but, if possible based in all elements.</li> </ol> <p>For example, for the following inputs:</p> <pre><code>[[2,3,4,5,6],[1,3,4,5,7],[1,3,4,5,8]] [[5,2,3],[2,2,4],[2,2,5]] </code></pre> <p>The output should be, respectively:</p> <pre><code>[[1,3,4,5,7],[1,3,4,5,8],[2,3,4,5,6]] [[2,2,4],[2,2,5],[5,2,3]] </code></pre>