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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:49:04+00:00 2026-05-23T06:49:04+00:00

Ok, this is a very easy question for which I could not find the

  • 0

Ok, this is a very easy question for which I could not find the solution here;

I have two lists A and B

A=(0,1,2,3,...,N-1)  (N elements)
B=(-50,-30,-10,.....,-45) (N elements)

I would like to create a new structure, kind of a 2D matrix “C” with 2xN elements so that

C(0)=(0,-50)
C(1)=(1,-30)
...
C(N)=(N-1,-45)

I could not get to this since I do not see an easy way to build such matrices.

Then I would like to get a new matrix “D” where all the elements coming from B are sorted from highest to lowest such

D(0)=(0,-50)
D(1)=(N-1,-45)
D(2)=(1,-30)
...

How could I achieve this?

P.S. Once I get “D” how could I separate it into two strings A2 and B2 like the first ones? Such

A2=(0,N-1,1,...)
B2=(-50,-45,-30,...)
  • 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-23T06:49:05+00:00Added an answer on May 23, 2026 at 6:49 am
    C = zip(A, B)
    D = sorted(C, key=lambda x: x[1])
    A2, B2 = zip(*D)
    

    Or all on one line:

    A2, B2 = zip(*sorted(zip(A,B), key=lambda x: x[1]))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry if this question is very easy, but I can't find the answer anywhere.
First, I know this is kind of common question, but I could not find
Let's make this very easy. What I want: @array = qw/one two one/; my
I thought this would be very easy. I downloaded the JDK, extracted src.zip, modified
I know this might be very easy to some,, I have a simple string
The idea it's very easy, i have an http download class, this class must
Firstly, I realise that this is a very similar question to this one: Which
This is probably a very easy question, but I never really did web... so
Maybe this is something very easy to do it but so far it's taking
This seems like it should be something very easy to do, but every time

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.