sort the stack