The Transport Layer of the OSI Model is where protocols such as UDP and TCP interact. We assign port numbers here as well. In this stage of the OSI Model, we deal with segments.
We now have a mechanism to determine if data is arriving in the correct order because, in the Transport Layer, we have a segment numbering system in place. It is up to the protocol used to determine how to handle situations where segments are arriving out of order. For example, UDP does nothing.
Connection-oriented protocols like TCP can perform a checksum to determine if data is corrupt.
We use the port numbers that get assigned to determine which application should get the data when we strip the packet to the 3 data/application-oriented layers (Application, Presentation, And Session).