Fixing Sorting, making it more configurable