Fixed Sorting Bugs