Port multi-dispatch candidate sort to NQP.

This is a fairly direct port of the C code rather than an attempt to
be a great deal more idiomatic. Not yet used for anything.