made pyramid_sort function python 3 compatible. fixes #1