[BitTorrent] Re: Bencoding: How to sort keys for dictionaries ?

Brian Dessent brian at dessent.net
Sun Nov 21 15:02:10 EST 2004

skybuckflying wrote:

> > It means they're sorted in lexicographical order.  This is a
> frequently
> > asked question so search the mailing list archives.
> I did that turned up nothing ;)

The first time it came up was a thread "How to calculate info_hash?"
from about 2003-May-17 on this list.  It has been asked several times
here and on btports since.

> So I think a typical sorting algorithm (which uses compares) will
> sort it just fine with a typical string compare function.

Yes, typical string sorting order.

> Well currently my implementation can store both the decoded and
> encoded value.

This does not make any sense.  There is only one key value.  "foo" or
"3:foo" both represents the same string.  Whether you choose to store
the key as a C-style string, a length-delimited string, or your
language's native string/scalar type makes no difference.  And that
choice has nothing to do with the bencoding standard as there is no such
thing as a "decoded" string in a bencoded file, by definition.


------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.

Yahoo! Groups Links

<*> To visit your group on the web, go to:

<*> To unsubscribe from this group, send an email to:
    BitTorrent-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:

More information about the BitTorrent mailing list