Improved the sort function to properly sort mixed numeric/text tokens.