Sorting a hash table based on value (not key)

V

vikas

Hi,

I want to sort a hash table based on value, not key. (key is of type
string which hashes to some value and in each node i am maintaining
frequency of that word(string) which is to be updated when that word
is found. Now i want to print the words in decreasing order of
frequency.
 
C

Chris Dollin

vikas said:
I want to sort a hash table based on value, not key. (key is of type
string which hashes to some value and in each node i am maintaining
frequency of that word(string) which is to be updated when that word
is found. Now i want to print the words in decreasing order of
frequency.

So what's not working?
 
C

CBFalconer

vikas said:
I want to sort a hash table based on value, not key. (key is of
type string which hashes to some value and in each node i am
maintaining frequency of that word(string) which is to be
updated when that word is found. Now i want to print the words
in decreasing order of frequency.

Take a look at the wdfreq.c demonstration application in
hashlib.zip release. See:

<http://cbfalconer.home.att.net/download/>

The leading comment in that source is:

/* Demonstration filter.
This scans an input file for words, which consist of alpha-
characters only, delimited by anything else. Each word is
converted into lower case, and entered into a database with
an occurance count. When all entry is complete the word
list is formed and sorted, and the results dumped in order
of number of occurances.

The database is implemented through use of the hashlib
package. When loaded, a singly linked list is formed from
the content by the hashwalk feature, and sorted with a
mergesort.

by C.B. Falconer, 2002-03-12
Put in public domain. Attribution appreciated.
*/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top