To get you the best answer I think some clarification is worthwhile is you are willing OP.
What do you mean by all sleeping together? Do you mean when sailrs began to transition away from hammocks they hung up every night?
As even today on many merchant, and especially military vessels, communal sleeping arrangements are very common if not the norm for at least the junior members of the crew.