Four types, no ambiguity
Bencode has integers, byte strings, lists, and dictionaries, and nothing else. d3:cow3:moo4:spam4:eggse decodes to {"cow": "moo", "spam": "eggs"}.
There is no float, no boolean, and no null. A torrent’s private flag is the integer 1, and a missing key is how absence is expressed.
Why keys are sorted
Dictionary keys must appear in sorted byte order, which makes the encoding canonical: the same data always produces the same bytes. That is what allows the infohash, a SHA-1 over the encoded info dictionary, to be a stable identifier for a torrent.
Re-encoding a decoded torrent with keys in a different order changes the infohash and produces a different torrent.
Strings are bytes
A bencoded string is a length and raw bytes, with no encoding declared. Text keys decode as UTF-8 here, and anything that is not valid UTF-8 falls back to hex, which is what the pieces field does.