javascript array sort

JavaScript
var fruits = ["Banana", "Orange", "Apple", "Mango"];

fruits.sort();        // Sorts the elements of fruits
         
            
        
     let numbers = [0, 1, 2, 3, 10, 20, 30];
numbers.sort((a, b) => a - b);

console.log(numbers);var points = [40, 100, 1, 5, 25, 10];
points.sort((a,b) => a-b)var numbers = [4, 2, 5, 1, 3];
numbers.sort(function(a, b) {
  return a - b;
});
console.log(numbers);

// [1, 2, 3, 4, 5]
homes.sort(function(a, b) {
    return parseFloat(a.price) - parseFloat(b.price);
});var points = [40, 100, 1, 5, 25, 10];

points.sort(function(a, b){return a-b});

 
Source

Also in JavaScript: