'sort whole object with specific (key->value) in JavaScript alphabetically?

I have an array in JavaScript that looks like

[
   {
      "name":"a",
      "phoneNo":"1"
   },
   {
      "name":"X",
      "phoneNo":"3"
   },
   {
      "name":"A",
      "phoneNo":"2"
   },
   {
      "name":"b",
      "phoneNo":"4"
   },
   {
      "name":"c",
      "phoneNo":"5"
   },
   {
      "name":"D",
      "phoneNo":"6"
   }
]

and I want to sort it by the name value in each array, alphabetically. NOTE: all name will be converted to lowercase first. I am stuck with this problem and I tried alot to solve it myself and also tried some research but I did'nt found something. Help!!!



Solution 1:[1]

Using lodash, you can easily solve the problem: use Lodash to sort array of object by value

_.sortBy(myArray, o => o.name.toLowerCase())

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ch271828n