sorted a stack