refactor sorting code, downcase params
fix typo in sortable