Advanced JavaScript Training
Array.Sort( )

Array.Sort( )

  • JavaScript provides a built-in Array.prototype.sort() method.
  • It sorts elements by converting them into strings and comparing their sequences of UTF-16 code unit values.
  
       const numbers = [5, 2, 1, 3, 4];
       numbers.sort((a, b) => a - b);

     
Have a doubt?
Post it here, our mentors will help you out.