Harbor Manifest Planner Log
The harbor logistics crew captures every incoming container as a single string in the form berth#cargo#sequence, logging exactly how the crane operator read it aloud. Shift leaders rely on those entries to plan the next round of shuttles, but the raw manifest mirrors the noisy arrival order instead of the steady flow required to stage forklifts and marshaling lanes. They need a helper routine that takes the recorded entries and returns a freshly sorted list, leaving the original manifest untouched, so supervisors can print a dependable plan without paging anyone back to reconfirm cargo.
Each entry keeps the characters that were written on the clipboard: mixed casing, hyphenated cargo names, and the berth nicknames that dispatchers prefer. The routine must sort the manifest by cargo tag alphabetically in a case-insensitive way, then by the numeric value of the sequence segment, and finally by berth name to break any remaining ties. Every string must survive exactly as recorded—no trimming, padding, or rewriting—only a new position within the list that respects those ordering rules.
Before the morning meeting, operations will compare the helper's output with a verified planning sheet. If any cargo appears out of position, they halt container flow until someone rechecks the queue. Deliver a list that aligns perfectly so the reconciliation prints in one pass, including the quiet case where no entries were captured and an empty list confirms the quay is clear.
Example 1:
Input: entries = ["PierA#cocoa#2","PierB#algae#7","PierB#algae#5","PierA#cocoa#1"]
Output: ["PierB#algae#5","PierB#algae#7","PierA#cocoa#1","PierA#cocoa#2"]
Explanation: Cargo tag "algae" precedes "cocoa", and the algae crates follow sequence order before berth names are considered.
Example 2:
Input: entries = ["Dock9#tea#12","Dock2#linen#3","Dock5#tea#1"]
Output: ["Dock2#linen#3","Dock5#tea#1","Dock9#tea#12"]
Explanation: Linen sorts ahead of tea, while tea entries remain in ascending sequence.
Example 3:
Input: entries = ["Slip3#Quartz#4","Slip1#amber#2","Slip1#Amber#1"]
Output: ["Slip1#Amber#1","Slip1#amber#2","Slip3#Quartz#4"]
Explanation: Cargo comparison ignores case, so both amber crates align before Quartz, and berth names settle the final ordering.
Related Problems
No related problems found
Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this problem.
