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
    • 233
    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:-

    1. var MyArray = [
    2. { Entry: { Fname: 'Micky', Lname: 'Jones' }, CustomerID: 56563 },
    3. { Entry: { Fname: 'Carlos', Lname: 'Jacques' }, CustomerID: 56598 },
    4. { Entry: { Fname: 'Carlos', Lname: 'Dante' }, CustomerID: 56587 },
    5. { Entry: { Fname: 'Tim', Lname: 'Marley' }, CustomerID: 56593 },
    6. { Entry: { Fname: 'Courtney', Lname: 'Smith' }, CustomerID: 56541},
    7. { Entry: { Fname: 'Bob', Lname: 'Smith' }, CustomerID: 56214}
    8. ]

    On using the sortBY(KEY) MyArray .sortBy('CustomerID');

    Output

    1. "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
Reset Password
Fill out the form below and reset your password: