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

  • SEARCH
  • Home
  • 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 7073323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:54:56+00:00 2026-05-28T05:54:56+00:00

I have got three similar json objects. Now i wish to join the entire

  • 0

I have got three similar json objects. Now i wish to join the entire list and then sort the complete list according to one of the index. Here, goes the objects description

Object 1

[{"link":"#","prod":"Fundamentals Of Software Engineering","price":" Rs. 200 "},{"link":"##","prod":"Real-Time Systems: Theory And Practice","price":" Rs. 394 "}]

Object 2

[{"link":"#","prod":"Fundamentals Of Software Engineering","price":" Rs. 200 "},{"link":"##","prod":"Real-Time Systems: Theory And Practice","price":" Rs. 394 "}] 

Object 3

[{"link":"#","prod":"Fundamentals Of Software Engineering","price":" Rs. 200 "},{"link":"##","prod":"Real-Time Systems: Theory And Practice","price":" Rs. 394 "}] 

Once, I join all of them , I wish to sort the complete array (new one) w.r.t to price index.

Any hint for this will be appreciated.
thanks 🙂

  • 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-05-28T05:54:57+00:00Added an answer on May 28, 2026 at 5:54 am

    if Object1 , Object2 and Object3 are JSON strings convert it to Javascript objects using eval function.

    Then merge them using concat method.
    http://www.w3schools.com/jsref/jsref_concat_array.asp

    var mergedArray = arr1.concat(arr2, arr3);
    

    Then sort using sort method in Javascript Array.
    ref : http://www.w3schools.com/jsref/jsref_sort.asp
    ref: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/sort

    var sorted = mergedArray.sort(function(a, b){
    
        // This function is used by sort method for sorting process
        // This function gets called with parameters a,b which are the elements in array (here product objects from your JSON)
        // if this function returns value < 0 a is placed before b
        // if this function returns 0 nothing is changed
        // if this function returns value > 0 b is placed before a
        // a.price.replace("Rs.", "") removes Rs. from price string. so "Rs. 200" becomes 200
        // parseFloat(a.price.replace("Rs.", "")) makes it number.  "200" becomes 200. "200.50" becomes 200.5
        // priceA - priceB returns -ve value if priceA < priceB, 0 if priceA = priceB, +ve value if priceA > priceB.
    
        var priceA = parseFloat(a.price.replace("Rs.", ""));
        var priceB = parseFloat(b.price.replace("Rs.", ""));
        return priceA - priceB;
    
    
    
    });
    

    Use return priceB - priceA; for descending order.
    jsfiddle : http://jsfiddle.net/diode/FzzHz/

    .

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

Sidebar

Related Questions

In Unix, I have got three main files. One of them is a library
I'm using Google Test Framework to set some unit tests. I have got three
I have got an UITableView. How to simply fill it with three elements, for
I have got as follows: use constant ABC => ('one', 'two', 'three'); and I
We have got a custom MembershipProvider in ASP.NET . Now there are 2 possible
I have asked a similar question before and while the answers I got were
I have got a string similar to the following 7bac91ba-55f1-4eaa-b480-162c98e65b6e or 571420b3 57b5 4617
I have got an HTML snippet similar to: <div id="root"> <div id="A" attrib_2="bar"></div> <div
I have got an XML node called 'structNumber' which has data similar to '4.2'
I have got below XMLEncode function in VBScript function. I want to write similar

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.