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.
Python’s dict is already a hash table.
To assign rank: