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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:53:35+00:00 2026-06-17T14:53:35+00:00

first = [{‘a’:’aaa’,’b’:’ccc’,’c’:’bbb’,’d’:’ddd’}, {‘a’:’bb’,’b’:2,’c’:1,’d’:3}, {‘a’:’cc’,’b’:22,’c’:11,’d’:33}] second = [{‘a’:’aaa’,’b’:’bbb’,’c’:’ccc’,’d’:’ddd’}, {‘a’:’bb’,’b’:1,’c’:2,’d’:3}, {‘a’:’cc’,’b’:11,’c’:22,’d’:33}] table 2 |’a’ |

  • 0
    first = [{'a':'aaa','b':'ccc','c':'bbb','d':'ddd'},
             {'a':'bb','b':2,'c':1,'d':3},
             {'a':'cc','b':22,'c':11,'d':33}]

    second = [{'a':'aaa','b':'bbb','c':'ccc','d':'ddd'},
              {'a':'bb','b':1,'c':2,'d':3},
              {'a':'cc','b':11,'c':22,'d':33}]

table 2

    |'a'  | 'b' | 'c' |'d'  |
    |'aaa'|'bbb'|'ccc'|'ddd'|
    |'bb' |1    |2    |3    |
    |'cc' |11   |22   |33   |

table 1

    |'a'  | 'b' | 'c' |'d'  |
    |'aaa'|'ccc'|'bbb'|'ddd'|
    |'bb' |2    |1    |3    |
    |'cc' |22   |11   |33   |

In the tables above, the order of first row is same. The second row attributes are the primary keys. Even if their order change, but the values beneath are fine, they are equal

I have two tables and they transform to list of dictionaries in my code.The first row of the table is key for the dictionaries. I have to compare these two such that even if the column order changes from second row onward, the two entities are same. So in the example above, they are same.

In other words, the keys of dictionary are not the primary key for the table. the second row attributes are. How to write a code to perform such comparison.

  • 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-17T14:53:37+00:00Added an answer on June 17, 2026 at 2:53 pm

    The function compare() compares if first and second match according to what I understood is your equality criteria, and returns True if they are equal.

    first = [{'a':'aaa','b':'ccc','c':'bbb','d':'ddd'},
             {'a':'bb','b':2,'c':1,'d':3},
             {'a':'cc','b':22,'c':11,'d':33}]
    
    second = [{'a':'aaa','b':'bbb','c':'ccc','d':'ddd'},
              {'a':'bb','b':1,'c':2,'d':3},
              {'a':'cc','b':11,'c':22,'d':33}]
    
    
    def compare(first,second):
        for a,b in zip(first, second):
            vals_a = list(a.values())
            vals_b = list(b.values())
    
            vals_a.sort()
            vals_b.sort()
    
            if vals_a != vals_b:
                return False
    
        return True
    
    print compare(first,second)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, here is what I would like to do: Row 1 Row 2 Row
First Table +--------+------------+-------+ | type | variety | price | +--------+------------+-------+ | apple |
First I will show you example tables that my issue pertains to, then I
First of all, this isn't for a keylogger, it's for an input in a
first take a look on this picture from localScope app : i have 2
first of all some details: I configured security as below in web.xml view plaincopy
first off I'm a noob to PHP but here is my problem. I am
First off, I'm coming (back) to Java from C#, so apologies if my terminology
First, some context: I'm a Python developer who has written a medium-sized application using
First i selected images from photo library to ALAsset Library and after that i

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.