Fixed some bugs, also made it so that the comparator can sort assending and descending.