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

Brian Dessent brian at dessent.net
Sat Nov 20 21:26:01 EST 2004

skybuckflying wrote:

> "Keys must be strings and appear in sorted order (sorted as raw
> strings, not alphanumerics)."

It means they're sorted in lexicographical order.  This is a frequently
asked question so search the mailing list archives.

> Also why do keys have to be strings.. is that really necessary..
> (since my implementation can easily handle other stuff as well...
> though I haven't tried yet for searching for keys :) I might
> need/make an Equals or so... function for that :) )

The whole concept a dictionary is to associate key and value pairs. 
That traditionally means string (scalar) values.  I don't see what the
objection is, the only other thing I can think of that would make sense
as a key value is an integer which can be represented just fine as a
string.  And yes it is a good idea to require key values to be strings
for consistency.


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!

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