json_stream_t now returns sorting hints.

This is needed so that we can combine index based sorting with in memory
sorting.
Patches through sorting hints to datum_stream_t.
In theory sorting by an index and a value works.
Fix a bug with index-value sorting.
Adds copious comments about sorting_hint_next.

Also refactors it a little bit because it makes it a bit easier to
understand.