Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8392567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:32:50+00:00 2026-06-09T19:32:50+00:00

I have an object array called Persons and would like to sort by one

  • 0

I have an object array called Persons and would like to sort by one of its members, I am new to javascript prorotype and not sure how to do this. The object looks like this:

[ Object { EntityId=0, Name="Edibert", Number="1234", Value=""}]

[ Object { EntityId=0, Name="Jairo", Number="1234", Value=""}]

So it has a few more items there for that array of object Persons. I know i can access the name by doing something like this.Persons[0].Name. But how can i sort it by Name?.

thank you so much

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T19:32:52+00:00Added an answer on June 9, 2026 at 7:32 pm

    You can do this without Prototype:

    Persons.sort(function(a,b) {
        if(a.Name < b.Name) { return -1; }
        if(a.Name > b.Name) { return 1; }
        return 0;
    });
    

    Use any properties of the object you want from within the sort function, so long as you return one of the following values:

    • (-1) if a is to appear before b in the final array
    • (1) if a is to appear after b
    • (0) if the two items being sorted are identical

    In reality, any negative or positive number would work as a return value, but -1 and 1 are conventional.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have converted an array to object data like this: <?php $myobject->data = (object)Array('zero','one','two');
I have an included javascript file thats initializes an empty array object called widgets
I have javascript object defined like this: function SocialMiner() { var verbose=true; var profileArray=new
for example say i have an object array called $list looks like this: <(stdClass)#16
I have an object called SampleObject that holds an array of strings called StringArray.
I have the following array called $order (as printed out by print_r): stdClass Object
So in javascript I have an array that looks about like this: [{x1:0,x2:2000,y:300},{x1:50,x2:250,y:500}] And
I have a custom object that contains an array (called children) where objects of
I have an associative array (object) of the following construction var menu = new
I have an array of objects in MATLAB and I've called their constructors in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.