Hello Reader!. If you dealing with a array full of unsorted keys then you can use some of the syntax to sort them in any order, Consider the cases below:-
var MyArray = [
{ Entry: { Fname: 'Micky', Lname: 'Jones' }, CustomerID: 56563 },
{ Entry: { Fname: 'Carlos', Lname: 'Jacques' }, CustomerID: 56598 },
{ Entry: { Fname: 'Carlos', Lname: 'Dante' }, CustomerID: 56587 },
{ Entry: { Fname: 'Tim', Lname: 'Marley' }, CustomerID: 56593 },
{ Entry: { Fname: 'Courtney', Lname: 'Smith' }, CustomerID: 56541},
{ Entry: { Fname: 'Bob', Lname: 'Smith' }, CustomerID: 56214}
]
On using the sortBY(KEY)
MyArray .sortBy('CustomerID');
Output
"Tim Marley(56214)", "Carlos Jacques(56541)", "Carlos Dante(56563 )", "Courtney Smith(56587 )", "MickyJones(56593 )", "Bob Smith(56598 )"
0 Comment(s)