Added ca_sort_offset_score_by_offset

Also renamed ca_sort_offset_score to ca_sort_offset_score_by_score to make the
intent more clear.  offset/score arrays must be sorted by offset before they
can be stored, because set operations and delta compression rely on the fact.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
Moved offset/score array encoding to a separate function

Before this change, buffers were allocated dynamically through realloc().  Now
we just allocate a large enough array to fit any data.  I added an XXX to the
code as a reminder to fix this later.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
Renamed TS_SAMPLE to SAMPLE

Because we support overloaded functions, we don't need to include the parameter
types in the function name.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>