β back to unit
Challenge
# sorting advanced
Photo Line-Up
Line up for the yearbook photo by height, shortest first β and kids of the SAME height stay in the order they were already standing. π·
You get names and matching heights. Print the names in photo order, separated by spaces.
Example:
Input: names = ["mia", "leo", "kai", "ana"], heights = [130, 120, 130, 110]
Output: ana leo mia kai
Sorting by height (110, 120, 130, 130) gives ana, leo, then mia and kai tied at 130 β since mia was standing before kai originally, the stable sort keeps mia ahead of kai.
π‘ need a hint?
sort-photo-lineup.pyπ given lines are locked β write your code in between
loading...