i have a 2nd array with that looks like this
[['He', 2], ['saw', 1], ['her', 2], ['walking', 1], ['so', 1], ['asked', 1]] i need to sort the array alphapticaly/by the number on the right
function sortText(arr, word) { if(word) return arr.map(function(item) { return item[1]; }).sort(); } *if the word parmeter is true then the array is sorted alphapticlly if it's false then the array is sorted by the numbers on the right *
the wanted result if(word==true) [['He', 2], ['asked', 1], ['her', 2], ['saw', 1], ['so', 1], ['walking', 1]] if(word==false) [['saw', 1], ['walking', 1], ['so', 1], ['asked', 1], ['He', 2], ['her', 2]]