0 out of 464 challenges solved
Write a function `sort_numeric_strings(nums_str)` that takes a list of strings, where each string represents a number, and returns a new list where the strings are sorted numerically (as integers). #### Example Usage ```python [main.nopy] print(sort_numeric_strings(['4', '12', '45', '7', '0', '100', '200', '-12', '-500'])) # Output: [-500, -12, 0, 4, 7, 12, 45, 100, 200] print(sort_numeric_strings(['2', '3', '8', '4', '7', '9', '8', '2', '6', '5', '1', '6', '1', '2', '3', '4', '6', '9', '1', '2'])) # Output: [1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8, 9, 9] print(sort_numeric_strings(['1', '3', '5', '7', '1', '3', '13', '15', '17', '5', '7', '9', '1', '11'])) # Output: [1, 1, 1, 3, 3, 5, 5, 7, 7, 9, 11, 13, 15, 17] ``` #### Constraints - The input list will only contain valid numeric strings (both positive and negative integers). - The function should return a new list without modifying the original input list.
def sort_numeric_strings(nums_str): """ Sort a list of numeric strings numerically. Args: nums_str (list of str): A list of strings representing numbers. Returns: list of int: A list of integers sorted numerically. """ # Convert strings to integers, sort them, and return the sorted list pass # Replace this with your implementation