Fixed sorting, it still needs work.