Generic sorts.

Finished converting sorting algorithms to use generic types.