Write a program to Sort a stack such that the smallest items are on the top. You can use additional temporary stack, but you may not copy the elements into any other data structure (such as an array). The stack supports the following operations: push, pop, peek, isEmpty.
We have used two additional Stacks for that. One is forward Stack to store the items in the sorted way such that greatest item is at the top, from the given stack. Another is backward Stack to store the sorted items in such a way that lowest item is at the top, from the forward stack.