refactor sortIt and remove comented out code

used @boonrs more concise and readable code in place of sortIt function. Remove commented out code