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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:53:08+00:00 2026-06-11T05:53:08+00:00

I have created a 2D matrix like this: 45 67 Row Fine 25 22

  • 0

I have created a 2D matrix like this:

45  67  Row  Fine
25  22  Abe  Real
58  54  Abe  Noon

Each column is a list. The values in the rows are connected together, so the values in the third row with the indexnumber 2 belong to each other.

I want to sort the rows, first on the third row, and then on the fourth row, so that it becomes:

58  54  Abe  Noon  
25  22  Abe  Real 
45  67  Row  Fine

I don’t know what way to go. I could sort one list, the one with the values of the third column. Then find out the new indexnumbers and compare them with the old. Then I could adjust the other lists as well, so that all rows are correct again. But then I still need to sort the fourth row.

I see some code for sorting a list of lists here , but I then need lists of rows instead of columns (if I understand it well).

Or is creating a dictionary a smart way to go?

  • 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-11T05:53:09+00:00Added an answer on June 11, 2026 at 5:53 am

    You have a list of columns. To make it into a list of rows, you can just use zip:

    iterable_of_rows = zip(*my_list_of_columns)
    

    Combining that with the typical way to do these sorts:

    import operator
    sorted_list_of_rows = sorted(zip(*my_list_of_columns), key = operator.itemgetter(2,3))
    list_of_columns = list(zip(*sorted_list_of_rows))
    

    And testing:

    >>> my_list_of_columns = [[45,25,48],[67,22,54],["Row","Abe","Abe"],["Fine","Real","Noon"]]
    >>> import operator
    >>> sorted_list_of_rows = sorted(zip(*my_list_of_columns), key = operator.itemgetter(2,3))
    >>> list_of_columns = list(zip(*sorted_list_of_rows))
    >>> list_of_columns
    [(48, 25, 45), (54, 22, 67), ('Abe', 'Abe', 'Row'), ('Noon', 'Real', 'Fine')]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a matrix report. I have a column 'Model' and values are
i created a matrix report that have 2 rows and 6 columns. picture 1
I have a bit of confusion regarding the matrix row/column order of the CATransform3D
I have a need to basically create a matrix of values in my Silverlight
Supose I have a matrix. This matrix is blank except some points that create
I am trying to create a matrix to look like this: [1 x x^2
I have a list of matrices, the first matrix of which looks as follows:
i have a text file that holds a 2-dimensional matrix. it looks like the
I have an algorithm where I create two bi-dimensional arrays like this: TYPE TPtrMatrixLine
I have created an open plane area with thin cylinders on it like pucks,

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.