SAP interview question

Explain Stack data structure, and write an algorithm to sort elements in the stack