Added sortMethod and fixed sort