BudiBadu Logo
00:00

Midnight Vendor Queue Order

Sorting Algorithms Medium 0 views

The midnight market runs an after-dark queue where each vendor registers as soon as their lantern cart reaches the plaza. Coordinators record every sign-up as zone|vendor|HH:MM, capturing the exact lettering from the badge and the moment stamped by the gate clock. By dawn the sheet looks frantic, making it hard to plan when to open power hookups or send runners. They need a helper routine that sorts this raw list and returns a new list in the precise order crews will greet vendors, without mutating the original records.

Every entry must keep its punctuation, spacing, and casing. Sorting should first use the HH:MM time segment in 24-hour format, interpreting it as minutes since midnight. If two entries share the same time, compare the zone alphabetically, and if the zone also matches, compare the vendor name using case-insensitive ordering while preserving the recorded text. No padding, trimming, or rewriting is allowed—only a re-ordered list that reflects those tie-breakers.

Before the music starts, the concierge checks the helper's output against the published vendor reel. A single card out of sequence triggers a stall while volunteers rearrange cords. Provide a list that aligns perfectly, including the quiet case where the queue is empty and the routine must return an empty list so staff know the plaza stayed dark.

Example 1:

Input: vendors = ["North|Lantern Press|19:30","South|Spice Cart|19:10","North|Tea Note|19:10","East|Gilded Loom|19:45"]
Output: ["South|Spice Cart|19:10","North|Tea Note|19:10","North|Lantern Press|19:30","East|Gilded Loom|19:45"]
Explanation: The earliest gate time appears first; ties at 19:10 favor the northern zone over south, then vendor names.

Example 2:

Input: vendors = ["West|Saffron Loom|20:15","East|Gilded Loom|20:15","West|Night Ivy|20:05"]
Output: ["West|Night Ivy|20:05","East|Gilded Loom|20:15","West|Saffron Loom|20:15"]
Explanation: Night Ivy leads because of an earlier time, while the two 20:15 entries sort by zone.

Example 3:

Input: vendors = ["South|ember & co|21:00","South|Ember & Co|21:00","Central|Aurora Bloom|20:50"]
Output: ["Central|Aurora Bloom|20:50","South|ember & co|21:00","South|Ember & Co|21:00"]
Explanation: Time controls first, zones tie next, and vendor names compare case-insensitively while keeping their original lettering.

Related Problems

No related problems found

Comments (0)

Join the Discussion

Share your thoughts, ask questions, or help others with this problem.

BudiBadu Logo

Midnight Vendor Queue Order

Sorting Algorithms Medium 0 views

The midnight market runs an after-dark queue where each vendor registers as soon as their lantern cart reaches the plaza. Coordinators record every sign-up as zone|vendor|HH:MM, capturing the exact lettering from the badge and the moment stamped by the gate clock. By dawn the sheet looks frantic, making it hard to plan when to open power hookups or send runners. They need a helper routine that sorts this raw list and returns a new list in the precise order crews will greet vendors, without mutating the original records.

Every entry must keep its punctuation, spacing, and casing. Sorting should first use the HH:MM time segment in 24-hour format, interpreting it as minutes since midnight. If two entries share the same time, compare the zone alphabetically, and if the zone also matches, compare the vendor name using case-insensitive ordering while preserving the recorded text. No padding, trimming, or rewriting is allowed—only a re-ordered list that reflects those tie-breakers.

Before the music starts, the concierge checks the helper's output against the published vendor reel. A single card out of sequence triggers a stall while volunteers rearrange cords. Provide a list that aligns perfectly, including the quiet case where the queue is empty and the routine must return an empty list so staff know the plaza stayed dark.

Example 1:

Input: vendors = ["North|Lantern Press|19:30","South|Spice Cart|19:10","North|Tea Note|19:10","East|Gilded Loom|19:45"]
Output: ["South|Spice Cart|19:10","North|Tea Note|19:10","North|Lantern Press|19:30","East|Gilded Loom|19:45"]
Explanation: The earliest gate time appears first; ties at 19:10 favor the northern zone over south, then vendor names.

Example 2:

Input: vendors = ["West|Saffron Loom|20:15","East|Gilded Loom|20:15","West|Night Ivy|20:05"]
Output: ["West|Night Ivy|20:05","East|Gilded Loom|20:15","West|Saffron Loom|20:15"]
Explanation: Night Ivy leads because of an earlier time, while the two 20:15 entries sort by zone.

Example 3:

Input: vendors = ["South|ember & co|21:00","South|Ember & Co|21:00","Central|Aurora Bloom|20:50"]
Output: ["Central|Aurora Bloom|20:50","South|ember & co|21:00","South|Ember & Co|21:00"]
Explanation: Time controls first, zones tie next, and vendor names compare case-insensitively while keeping their original lettering.

00:00
Loading editor...
Test Results

Run your code to see test results

Click the Submit button to execute your solution

Related Problems

No related problems found

Comments (0)

Join the Discussion

Share your thoughts, ask questions, or help others with this problem.