Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to sort an given array using Javascript

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 219
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: