mode() is sort-of working. Fails on unsorted input for some horrendously weird reason