Added basic PREPARATION for sorting functionality
fixed sort paramethers