Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

252
Visualizações
array.sort((a,b)=>a-b)) the a, b arguments parameters

array.sort((a,b)=>a-b))

when I use the sort() method to numbers array, what kind of rules do they use to pick a and b from the numbers array?

when I log the a and b in the console, it seems to show array[1] as b, array[0] as a and so on, but when the array is different, it shows different rule.

Is there any way to see how sort()method pick the arguments from the numbers array?

array will be like [2,20,60,300,1000] or longer.

Thank you.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The sort function is a native function, it means that it is implemented by the browser javascript engine in language X ( c++ or java usually ) and you cannot edit or modify them.

If you want a custom sort function you need to write your own or find one that fits your needs.

Why you need to know how the sort function manage the given array?

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda