← back to unit
Medium
# sorting medium
Sort by Name Length
Name tags come in sizes — print the names shortest first so the tag machine works down the pile. 🏷️
You get a list of names. Sort them by LENGTH (shortest first); names of equal length keep their original order. Print comma-separated.
Example:
Input: names = ["bella", "jo", "maximus", "ana"]
Output: jo,ana,bella,maximus
Sorted by length (2, 3, 5, 7) — "jo" is shortest, "maximus" is longest.
💡 need a hint?
sort-by-name-length.py🔒 given lines are locked — write your code in between
loading...