fix bug with crazy sorting bug that caused tons of stuff to fail + regression test