added additional sorting function
corrected an error