Fix for differences in sorted between python 2 & 3