There could have been a std::stack::sort template using two auxiliary stacks and polyphase merge sort (time complexity O(n log(n)), see below), or the template could have been implemented based on the underlying container type: std::deque, std::list, or std::vector, since the container type can be specified for std::stack, such as:
std::stack <int, std::vector<int>> mystack;
std::sort can be used for std::deque or std::vector (both have random access iterators), and std::list::sort for std::list. I don't know if other container types or custom container types are allowed for std::stack; if allowed, this would present an issue for trying to create a std::stack::sort based on the container type.
using an auxiliary stack to sort the original stack
A stack sort with one auxiliary stack has O(n^2) time complexity. A stack sort with two auxiliary stacks, based on polyphase merge sort, has O(n log(n)) time complexity, but the code is complex. It would be faster to move the stack to an array or vector, sort the array or vector, then create a new sorted stack.
If you're curious about a polyphase merge sort for 3 stacks (the original and 2 auxiliaries), I wrote examples linked to below. These use a custom stack container based on an array, and are about as fast as a standard merge sort on array, but require 2 temporary stacks.
A long time ago, polyphase merge sorts were used for tape drives. Some tape drives could read backwards, to avoid rewind times, essentially making them stack like containers (write forwards, read backwards). With tape drives, file marks or records of different size could be used to indicate end of run, eliminating the need to keep track of run boundaries with the code. Many of the advanced versions of commercial polyphase merge sort programs were proprietary, and the knowledge essentially lost over time as tape sorts faded away into history.
https://stackoverflow.com/a/38419908/3282056