Added Sorting
Fixed sorting bug.