Changed the sorting method to account for the char ordering.