Added re-organize function to order rest stacks