Please help on "return largest numbers in arrays"

Tell us what’s happening:
Describe your issue in detail here.
I am trying to use the sort method to sort out the individual arrays but for some reason, numbers greater than 3 digits like 1001 are not moving to the end of the arrays with sort. Please help!

  **Your code so far**

function largestOfFour(arr) {
let myArray = [];
for (let i = 0; i < arr.length; i++) {
  for (let j = arr[i].length - 1; j >= 0; j--) {
return arr;

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [999, 1001, 857, 1]])
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36

Challenge: Return Largest Numbers in Arrays

Link to the challenge:

i dont think using sort will solve it,u just have iterate through the array,create a max number and ask if the max is greater than the num u are iterating

The reason is simple: it does convert all entries to strings and then sorts them as that. And in a dictionairy “Automobile” comes before “Zoo” despite one being much longer than the other → same with 1001 and 807.

You’d either need a workaround to make .sort() work with numbers OR find another way to do it.
Also your inner loop is completly pointless - you are literally breaking out of the loop in the first run. Maybe you can think of a way to not use a loop, if you are not looping anyway? :wink: