Replace custom sort algorithm with generic version

Replace custom sort algorithm with a version that uses stock
libraries. This does not improve performance, just readability.
Implement external bucket sort

- Add a basic external bucket sort algorithm and supporting code.
  This will be slower that the internal sort but uses far less
  memory. This will fix #145 (in theory)
- Change boolean 'fast_sort' setting to "enum" 'sort' setting to
  allow for multiple sort types