Added charsort function