Two methods: 1) If you need your hash only once in an infrequent while, then save the elements in a list, appending as needed, and sort prior to hashing, as needed
2) If you need your hash more often, you could keep your elements in a treap or red-black tree; these will maintain sortedness throughout the life of the datastructure. 3) If A bunch of log(n) or n or nlog(n) operations doesn't sound appealing, then you might try this one: Create some sort of mapping from your elements to the integers. Then just use a sum. This won't scatter things nearly as well as a cryptographic hash, but it's very fast, because you don't need to reevaluate some of your members as you go. HTH On 11/30/11, Neal Becker <ndbeck...@gmail.com> wrote: > I like to hash a list of words (actually, the command line args of my > program) > in such a way that different words will create different hash, but not > sensitive > to the order of the words. Any ideas? > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list