Yes
This is something you can do. If you have two attacks from the Extra Attack feature, you can even fire from the longbow, then hold the bow in one hand, draw the sword, and attack with it with thefor your second attack. You can also sheathe the sword and attack with the longbow again on your turn in the following round. You seem to grasp the limitations of those actions.