#C14856. Process Names by First Letter
Process Names by First Letter
Process Names by First Letter
Given a list of names, your task is to create a dictionary by grouping the names according to their first letter (case-insensitive). Only include valid names (i.e., strings) in your result. For each group, sort the names in alphabetical order.
If the input list is empty or if there are no valid names, output an appropriate error message. Specifically, output Input must be a list. if the provided input is not a list, and No valid names provided. if the list does not contain any valid string names.
Note: Any formulas in your solution must be formatted in LaTeX if used (e.g., $x = y+z$). In this problem, there are no formulas.
inputFormat
The input is provided through standard input (stdin) as a single JSON-formatted value. It is expected to be a JSON array of names. For example:
["John", "Jack", "Albert", "Andrew", "Jim"]
outputFormat
If the input is valid and contains at least one string, output the resulting dictionary in JSON format with keys sorted in ascending order. For example:
{"A": ["Albert", "Andrew"], "J": ["Jack", "Jim", "John"]}
Otherwise, output the error message exactly as specified.
## sample["John", "Jack", "Albert", "Andrew", "Jim"]
{"A": ["Albert", "Andrew"], "J": ["Jack", "Jim", "John"]}