My array object is like below example.
[
{'email':'[email protected]', 'name':'abc'},
{'email':'[email protected]', 'name':'bbc'},
{'email':'[email protected]', 'name':'aaa'},
{'email':'[email protected]', 'name':'cba'},
{'email':'[email protected]', 'name':'cab'},
]
So my new array will have key value pare of alphabet A as a key and values are all object that's name start from A alphabet and so on.one more thing is if alphabet A has 2 objects that start from a then I also want to sort then in ascending order as I show in final output example below
final output I want is like this.
[
"a" : [{'email':'[email protected]', 'name':'aaa'},{'email':'[email protected]', 'name':'abc'}],
"b" : [{'email':'[email protected]', 'name':'bbc'}],
"c" : [{'email':'[email protected]', 'name':'cab'},{'email':'[email protected]', 'name':'cba'}]
]