Question: Implement a comparator NumStrComp on strings that does the following: for each digit and letter, it assigns a number (0 = 0, 1 = 1,
Implement a comparator NumStrComp on strings that does the following: for each digit and letter, it assigns a number ("0" = 0, "1" = 1, "2" = 2, ..., "9" = 9, "A" = 10, "B" = 11, "C" = 12, ..., "Z" = 35; same numbers for lowercase letters as for uppercase letters); all other characters are 0. It then simply adds up all the numbers assigned to all digits and letters in the string, and sorts by the sum. Ties are broken lexicographically, i.e., with the "standard" string comparison for C++. Add the functor NumStrComp to functor.cpp and functor.h.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
