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 7513039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:03:20+00:00 2026-05-30T00:03:20+00:00

I have a sort problem. I have two array int a[] ={index1,index2,index3…indexI}; int b[]

  • 0

I have a sort problem.

I have two array

int a[] ={index1,index2,index3...indexI};
int b[] ={num1,num2,num3.......numI};

Array b[] is having numbers in random order but their position corresponds to position in a[].
For example num1 is the value of index1, num2 is the value of index2.

The problem is:

I need to sort the b[] elements in descending order, at the same time I need to move the a[] elements position according to the sorted order of b[].

I can sort b[] in descending order using one of the sort algorithm but I am not able handle the simultaneous move of the a[] elements according to the b[] position change.
My final output I am expecting is a[] indexes arranged in descending order of their values in b[].

Please help.

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-30T00:03:22+00:00Added an answer on May 30, 2026 at 12:03 am

    If I get it correcty yu want to have something like this a = [0 1 2]; b = [5 2 8] and after sorting a = [1 0 2]; b = [2 5 8].

    Which ever sorting algorithm you must just remember to change index arrays when changing number’s position:

    eg. swapping two positions (pseudocode)

    swap(i, j): // i, j - indexes
       (b[i], b[j]) = (b[j], b[i]) // swap values
       (a[i], a[j]) = (a[j], a[i]) // swap the indexes
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have seen a few days ago such problem there is given two array
I have sort of a tricky problem I'm attempting to solve. First of all,
I have some sort of a design problem with my Django AJAX application. I
I have a problem with how the List Sort method deals with sorting. Given
i have one problem when i sort the NSMutablearray using date and time wise.
can anyone help, i have problem doing a sort, I thought i had it
suppose that we have three array int a[]=new int[]{4,6,8,9,11,12}; int b[]=new int[]{3,5,7,13,14}; int c[]=new
I have combined two arrays using array_merge, and now need to sort them alphabetically.
i have some problem to understand array_multisort See how it sorts when two values
I have two arrays that I need to sort A->Z but all numerical indexes

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.