My goal is to arrange three arrays (array1, array2, and array3) in ascending order based on their first element to display the following sequence.
1, banana, 2, grapes, 3, oranges.
Even though I've written the code below, I am facing difficulty sorting it as I desire:
var array1 = ["1", "banana"];
var array2 = ["3", "oranges"];
var array3 = ["2", "grapes"];
var array4 = [];
function myFunction(){
array4.push(array1, array2, array3);
alert((array4).sort(function(a, b){return a-b}));
}