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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:38:40+00:00 2026-05-29T10:38:40+00:00

I want to implement a hash table in python. On the table a class

  • 0

I want to implement a hash table in python. On the table a class object will be associated with the key value. The problem is I want to use the key value to find the index of the class and update it (which of course is not a problem). But what can I do if I want to sort the table using a particular value of the class.

For example, let us consider, we have three value: document_id, score and rank. There is a class “document” which consists of “score” and “rank”. “document_id” will be the key of the table.

I want to update the “score” of various entries of the table, using the key: “document_id”. But when updating of the scores are done, I want to sort the list/table using the score and assign rank value to the “rank” variable based on updated score.

Can someone kindly give me some guideline about how can I proceed? Or maybe I should simply make it a list?

The maximum number of item of the table might be upto 25000-30000.

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-29T10:38:41+00:00Added an answer on May 29, 2026 at 10:38 am

    Python’s dict is already a hash table.

    doc_hash = {}
    doc_hash[doc.id] = doc
    

    To assign rank:

    docs = sorted(doc_hash.itervalues(), key=operator.attrgetter('score'), reverse=True)
    for i, doc in enumerate(docs):
        doc.rank = i
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement a Chord distributed hash table. I want to use SHA-1
I want to implement a fast hash function that will use int datatype and
I want to implement some sort of lookup table in C++ that will act
So I'm attempting to implement a hash table that will hash structures containing words.
I want to create a class which will have two properties, e.g. key &
I would like to use a custom object as a key in a hash-like
I want to use a distributed hash table in an application but I don't
I want to implement an algorithm that needs to use a hash tree. What
given this class definition: public class Frame { IFrameStream CapturedFrom; } I want implement
I want to implement a paperless filing system and was looking to use WIA

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.