Sort the stack