Added alphabetical sorting (python's own alphabetical sorting gives priority to uppercase letters) to the traverse() function.