Sort Stack
Write a program to sort a stack such that the smallest items are on the top.
You can use one additional temporary stack, but you may not copy elements into any other data structure (such as an array).
The stack supports: push, pop, peek, and is_empty.
Example:
Input stack (top first): [1, 3, 9, 5, 8]
Output stack (top first): [1, 3, 5, 8, 9]
Hints
solution.py
Python ready
Test Output
▶
Click "Run Tests" to execute your code